0

Throwing AuraHandledException will stop email from being sent, so that I can't throw AuraHandledException to alert LWC and send a email in the same transaction.

My option will be either a) separating the call into 2 sequential calls. b) sending a custom message instead of throwing exception.

Did I miss anything or do you think there's a better approach?

1 Answer 1

3

Publish a Platform event using "Publish Immediate" - this will not be rolled back. Use a Flow or Apex Trigger to subscribe to the Platform Event and send the email. FWIW - I've written a lightweight Logging Framework that uses this same principle to write error logs to a custom object. Logging Framwork GitHub project

1
  • This is a good one, Thanks!
    – yongabyte
    Jul 8, 2022 at 21:49

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.