Abort the execution in business rule and refresh the record

Khanna Ji
Tera Guru

How to refresh the current record with values stored in the database after abort action?

gs.addErrorMessage('You are not allowed save the record.');
current.setAbortAction(true);
action.setRedirect(current);

above code is aborting the execution but not keeping the user selected data in the fields. I want to revert back to the previous data.

15 REPLIES 15

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Swathi,

Are you saying that user filled some data in some fields and your before business rule aborted and you want to reload the form with the same data what user entered before submitting?

If yes then that won't be possible since when you redirect to the current record the values for the fields are shown as per database. The values user has entered are not in database yet since action was aborted.

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Values are not showing as per the database. System is aborting the transaction but keeping the data that user selected or entered.

 

Eg. When a user opens existing incident its state is Pending in the database. When user set it to Cancel, I am aborting the transaction but form shows cancel only not Pending.

When I refresh the form, it is showing me the pending value.

Hi.

Try

 

gs.addErrorMessage('You are not allowed save the record.');
current.setAbortAction(true);

current.state=previous.state;

current.category=previous.category;// Like this add the required fields.

 

 

Hit correct or helpful based on the impact.

not working. added exactly same code but form still shows user set data on form but not the actual data in db