0

how to rollback the changes when there is error in promise chain.

for example: promise has 3 methods

  • verifytheValue
  • savetheRequest
  • sendToAws

In savetheRequest method we are sending email to few users. we cant bring that logic to sendToAwsMethod.

So whats happening here :

In sendToAws method is failing but still Email is triggering to particular Users. If all 3 method is successfully. then only mail should trigger. How to do this??

send email logic in Apex side. Please let me know if these Information are not enough to answer the question.I will update the question

1

You can't roll back a transaction once completed. In your case, you may want to simply change the order of execution (verify, send to aws, then email). Or, if possible, just write a fourth method that calls each of the other three in succession so you can do it all at once, if possible.

4
  • this way not possible in my case : verify, send to aws, then email. ill write fourth method and try it. thanks sfdcfox – Annappa Mar 20 '20 at 11:07
  • but how to check all 3 methods got success in javascript promise – Annappa Mar 20 '20 at 11:18
  • 1
    @AnnappaPH Promise.all([method1(),method2(),method3()]).then(result=>{...}).catch(error=>{...}) – sfdcfox Mar 20 '20 at 11:19
  • got it. Thanks.. – Annappa Mar 20 '20 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.