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

Community Alums
Not applicable

Senario :- If the record with same short description is created then abort the operation.

We can do this senario with after business rule as

(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    var gr = new GlideRecord('incident');
    gr.addQuery('short_description', current.short_description);
    gr.query();
    if (gr.next()) {
        current.setAbortAction(true);
        gs.addErrorMessage("duplicate value inserted");
    }

})(current, previous);

This will help to validate if same short description is  created it will abort the action and send the error message.