Retrieving associated opportunity with iSDK?

I’ve got a saved search that I’m calling with the iSDK in PHP to get the list of contacts that I need to access Opportunities for.

Does anyone know how to either find an existing associated Opportunity or create a new one starting from a Contact ID? Thanks for any pointers!!!

You can achieve this via Keap REST API and Keap REST API

This LIST endpoint doesn’t provide a contact filter, but you could go through each opportunity and filter on your end. XML/RPC does expose Opportunities via DataService using the Lead table (older terminology), which will allow you to filter by contact.

Great, that was really helpful. I’ve got almost all of what I need.

The one thing I can’t figure out is how to update the Stage. I can see it being returned as “OpportunityStage.stageID” (and it’s returned as a String). I’ve tried setting the same thing, “stageID” and “stageId” (just for fun). “OpportunityStage.stageID” gives me a NoFieldFound error, but neither “stageID” nor “stageId” give an error or update the field. I’ve tried setting them both to the string value as well as the index value of the dropdown on the UI.

@bradb Do you know how I can update the stage?

Thank you!

The stage is its own object so you just wrap it in a json object

  "stage": {
    "id": 123

For a programmer better than I am, that would probably be sufficient. Unfortunately, I’m still struggling with just the syntax. Here’s my command:

$result = $app->dsUpdate('Lead', $application['Id'], array(
           "_SchoolName" => $applicationContact[0]['_SchoolName1'],
           "stage" => json_encode(['id' => 5]),

That failed with the same ERROR: 10 - [NoFieldFound]No field found: Lead.stage. I knew that didn’t really look right though so I tried getting cleverer and doing something like:

$stageObj = json_encode(array(“stage” => [“id” => 5]));

And then passing $stageObj as parameter in the dsUpdate() method but that was also a no-go.

Any additional help getting over the finish line here?

It looks like you are trying to use the JSON/REST syntax with the xmlrpc endpoint DataService.update. The REST portion of the SDK is probably not up to date to allow for updating the opportunity records since it was recently released. The field name for the xmlrpc version is StageID and it should just be an int

Yesssss. Thanks a ton, @bradb. Enjoy your holidays!!