function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
blueandgoldblueandgold 

Order of execution with lead conversion via API

Hi folks,

 

We currently have a PHP script that sends a record to the Lead object, and include in that a campaign ID.  We then have built three triggers that do the following:

 

1) a trigger on insert on the Campaign Member, that when the lead record is created with a campaign ID, it creates a campaign member and then does an auto-conversion of the Lead

 

2) a trigger on insert on the Opportunity, which when the converted opportunity is created, updates the stage and closed date fields

 

3) a trigger on update on the Lead, which is fired when the lead conversion process finishes (which is the updating of the Lead record by the lead conversion process to associate the lead record in question to the newly created account, contact, etc)

 

What we'd like to do is have our PHP not only execute the request to create the new lead (which fires the chain of events above), but also catches a response from Salesforce that includes the newly created Lead record's ID.  Once we have that, we want to immediately have our PHP application hop into the Account that was just created in the lead conversion process and update a few fields (long story why we need to do it this way).

 

My questions are:

 

Based on the chain of events above, when would Salesforce provide our PHP application a success response on the Lead record creation?  Does that happen all the triggers above fire, and the lead is actually in its converted state due to the order of operations in SFDC?

 

Cheers!

TheIntegratorTheIntegrator

as far as I know, Salesforce API will return after exectution of all before/after triggers, workflows and validations just to make sure there wasn't any error generated.

 

You can then query with the LeadId returned to check if it was converted and get the convertedAccountId