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
Rajwant SainiRajwant Saini 

I have a Before insert trigger on Contact class, which is calling a Future method from different class.

I have a Before insert trigger on Contact class, which is calling a Future method from different class.
That future method calls a web url whch returns a value.
How do I take that returned value back to Trigger?

 
Ravi Dutt SharmaRavi Dutt Sharma
Future method runs in async mode and your trigger works in sync mode. So there is no way to get the response of future method back to the trigger.
MarkLMarkL
If you're looking to update the Contact based on the information received from the future method, I'd recommend placing the call to the future method in an After trigger instead. This way you can be sure the Contact has a Salesforce ID, and you can pass that Salesforce ID to the future method and inside the future method query for and update the Contact as needed.