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
Natasha AliNatasha Ali 

How to write a trigger to call an api after update?

Hi,
I'm new to development and need to create a trigger which will call an API to GET information from a third party app, then use the data retrieved to update a couple of picklist values in salesforce on the corresponding record. The record's unique identifier is the email address, which it will use to identify which record in the third party app to retrieve the data from.  How would I write the class to call the API and where would I begin with creating the API? I've exhausted the resources and I'm still a little lost. 
The trigger would be on the account object and would run when a picklist value changes (so a record is updated), and I need it to also update 2 picklist values on the record with the values retrieved from the callout. 

Any help is much appreciated,
Many Thanks :)
Natasha 
Rohit Kumar SainiRohit Kumar Saini
Hi Natasha,

In your trigger, you can check Account records qualifying to be processed ( having picklist value changes). You can collect them and call a future method passing the records. Trigger can't make callouts and we will have to do it asynchronously. You can use Queueable classes or use a Future method which should get Id/Ids, query the record(s), make callout and update the same records once get the response.

Thanks.