You need to sign in to do that
Don't have an account?
Justin Kitagawa 6
Avoiding recursive Future Calls
I am working on a project where I am hoping to do the following:
On Lead Insert --> Trigger to call @future callout method to get append information on the lead.
Query Lead database to find if other leads exist for that company (using email domain)
--> If New Company
--> call @future callout method to search for additional leads and bring them in as leads.
--> call @future callout method to append information to these leads.
But I am running into an issue as my Update call is triggering my insert call, which is then triggering the update call again and I am getting an error as a future method cannot be invoked by another future method...
I am thinking of either:
Any help would be greatly appreciated
On Lead Insert --> Trigger to call @future callout method to get append information on the lead.
Query Lead database to find if other leads exist for that company (using email domain)
--> If New Company
--> call @future callout method to search for additional leads and bring them in as leads.
--> call @future callout method to append information to these leads.
But I am running into an issue as my Update call is triggering my insert call, which is then triggering the update call again and I am getting an error as a future method cannot be invoked by another future method...
I am thinking of either:
- Making the second API call append data to the newly created additional leads included in the method to insert them in the first place
- Making the call to get additional leads scheduled instead.
Any help would be greatly appreciated
You may want to try using below approach :
Suppose that you had the following class.
A trigger that uses this class could then selectively fail the first run of the trigger.
For a deep dive : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_static.htm