We have a very complex scenario where we have multiple external systems that we interact with and we need to make sure the data is valid across multiple external systems before it gets processed within Salesforce. I know there is Queueable Asynchronous Transaction in Apex, but I'm looking for something similar to Promises in JavaScript.
So in JavaScript, it would be something like this....
var p1 = helper.calloutExternalSystem(component,'verifyExternalSystem1');
var p2 = helper.calloutExternalSystem(component,'verifyExternalSystem2');
var p3 = helper.calloutExternalSystem(component,'verifyExternalSystem3');
var p = Promise.all([p1,p2,p3]);
p.then(function(result){
console.log('Promise.all');
console.log(result);
});
In Salesforce Apex, how can we achieve something similar in Apex? If it's not doable in Apex, how do most work around the situation? Any guidance is greatly appreciated.
p1, p2, p3
must be successfull and only then the promise p should be executed? In other words p is the transaction that will be rolled back / not executed if one ofp1, p2, p3
were unsuccessfull. Is this the case? Isp
meant as a transaction?