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

Hi Swathi,

Displaying error message is fine but showing the data which is previous one before user changing the data is not possible without reloading the form. This is a fact.

Regards

Ankur

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

Are you sure? Then what is the meaning of previous and current? why Its not working for me?

Hi Swathi,

current and previous would work in business rule. How are you using it in your scenario and how do you think it would help you to show the previous values without the form being refreshed?

Regards

Ankur

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

Hi Swathi,

Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.

Regards
Ankur

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

manishp
Tera Contributor

Its a fact that unless you reload the form, you won't see previous values on form if Before business rules is running even after aborting the action using current.setAbortAction(true). But another fact is that new values shown are just virtual and not submitted to database since you have aborted the update action.

Reload the form manually to see previous(database) values. If you don't want to reload the form then use below code in your before business rule-

current.setAbortAction(true);

current.state=previous.state;

current.category=previous.category;

Even this action is not triggering any update action on database sever since previous and current values are same. So cheers.