You need to sign in to do that
Don't have an account?
John Cleveland
Help updating record with HTTP Request callout from Trigger
I have a trigger that calls a class that makes an http callout. I want to update the record that invoked the trigger with a value in the response from the http callout. I'm getting a response back but need help getting it saved in the Number Stage field on the Order object. Any help would be greatly appreciated.
Here's the trigger that calls the class:
This is the class that's being called:
Make your HTTP callout function
Public Static Integer postNumberCheck(string Number,id OrderId)
{
----- Your code
----
return numberReturn;
}
In TRIGGER
trigger NumberCallout on ORDER__c (before insert) {
for (ORDER__c order: Trigger.new) {
If(order.Number__c!= '00000')
{
order.Number__c= checkNumberStage.postNumberCheck(order.Number__c,order.id);
}
}
}
Make your HTTP callout function
Public Static Integer postNumberCheck(string Number,id OrderId)
{
----- Your code
----
return numberReturn;
}
In TRIGGER
trigger NumberCallout on ORDER__c (before insert) {
for (ORDER__c order: Trigger.new) {
If(order.Number__c!= '00000')
{
order.Number_Stage__c= checkNumberStage.postNumberCheck(order.Number__c,order.id);
}
}
}
It's making me use void due to the @future callout?
Yes - you cannot return anything from an @future call. Think about it - there's nothing on the other end waiting to receive that return value.
I also notice that you don't actually have an Order object in the postNumberCheck() method to update. Try this:
Good luck!