Skip to main content

Hi all,

 

When a material requisition change status, I have to do a validation, and generate 2 steps, when the validation is not ok:

 

  1. Send an email.
  2. Show an error on screen

The validation is ok, I have a function to validate and send the email if is FALSE, and a procedure to do the same validation, but show the error message on screen.

 

But I have a problem, if the on screen error shows, the email is not being sent.

 

please your help with this topic.

 

Best regads.

 

David P.

@David.Pintado do you show the toast error message using Error_Sys package inside your event action?

Then once the error is thrown there will be an implicit rollback of the Oracle transaction. I guess you would need to implement some error handling in your event action code to send the email and commit and then show the error to the user. See some example provided by Damith @dsj in the below post. 

 

 


Concur with @Marcel.Ausan , although be careful as if you commit during the error handling portion, any previous transaction code (done before the event trigger, basically), will STILL commit.

 

So for instance, let’s way you modify a field value from A to B, and you have an event triggering on this for validation, if your event code ends up raising an error, and then during that error handling you commit then send an error message, it will commit the change from A to B!

 

You can safeguard against that by having your exception handling FIRST rollback the transaction, THEN send an email, THEN commit, THEN raise error_sys.record general. That way, you rollback the A→B change, send and commit the email, then raise the error message.

 

Another possible option is to send the email through an autonomous_transaction subprocedure, that you call right before you raise through error_sys.

 

That way, the mail transaction will commit but the rest of the transaction will be rolled back and the error message will appear on screen :)


Reply