You need to sign in to do that
Don't have an account?

First RESTful API integration HELP!!!
Hi,
I'm completely new to development and I need to develop an integration between Salesforce and a third party service (BKSB). Salesforce needs to consume the REST API.
I need to write a trigger that will make a callout when a status changes on the custom 'Placement__c' object from '8 - Offer Accepted' to '9 - Induction Booked'. I have the following code so far (asked another dev):
And where do I go from the trigger?
ANY help is much appreciated!!
Many Thanks,
Natasha
I'm completely new to development and I need to develop an integration between Salesforce and a third party service (BKSB). Salesforce needs to consume the REST API.
I need to write a trigger that will make a callout when a status changes on the custom 'Placement__c' object from '8 - Offer Accepted' to '9 - Induction Booked'. I have the following code so far (asked another dev):
trigger PlacementTrigger on Placement (before update) { Map<Id,Placement__c> newPlacList1=new Map<Id,Placement__c>(); Map<Id,Placement__c> oldPlacList2=new Map<Id,Placement__c>(); List<Placement__c> newPlacementList=new List<Placement__c>(); newPlacList1=trigger.new; oldPlacList2=trigger.old; if(Trigger.IsUpdate && Trigger.isbefore ){ for(Id placId : newPlacList1.keySet()){ if(oldPlacList2.get(placId).Status__c == '8 - Offer Accepted' && newPlacList1.get(placId).Status__c == '9 - Induction Booked'){ newPlacementList.add(placList1.get(placId)); } } PlacementTriggerHandler.handlerFunction(newPlacementList); } }To identify the correct user's data to GET from the BKSB, the unique identifier is the email address on the Salesforce record. How do I incorporate this so the correct record is chosen in BKSB?
And where do I go from the trigger?
ANY help is much appreciated!!
Many Thanks,
Natasha
Trigger is to capture the event do a callout to external system.
In the above trigger, you have to call the external Rest API. So to call the BKSB Rest API, you have to import the WSDL of BkSB into Salesforce, then it will create a Apex class.
In the above trigger, call that apex class to connect and send the data to BKSB.
First do the below trailhead tutorial, so that you will get the good idea of apex callout.
https://trailhead.salesforce.com/content/learn/modules/apex_integration_services/apex_integration_rest_callouts
Thanks,
Naren
You will have to use future methods to make REST callout to the external system. Following is a code model for that:
Please go through the Apex REST Callouts unit from : https://trailhead.salesforce.com/en/content/learn/modules/apex_integration_services trailhead module. Also as far as uniquely identifying the records in BKSB is concerned, they should let you know the JSON format for the request. for example a sample JSON request may look like this:
"placmentList" :[ "placement":{
"email" : "ajax@gmail.com",
"name" : "ajax",
"institute" : "XXX University"
},
"placement":{
"email" : "zenon@gmail.com",
"name" : "zenon",
"institute" : "YYY University"
},
"placement":{
"email" : "beta@gmail.com",
"name" : "beta",
"institute" : "ZZZ University"
}
]
If this helps, please like and mark resolved.