current.setAbortAction(true) causes the error message 'Invalid update'

Andrew Pishchul
Giga Expert

Guys,
I got stuck with current.setAbortAction(true) in a business rule... I have a simple business rule on an incident table:
When:

Before

Update:
yes

Condition:
current.category=='Software'&& !current.hasAttachments()

Script:
gs.addInfoMessage("No attached documents found! Operation cancelled.")
current.setAbortAction(true);


But this rule causes and error message 'Invalid update' when I try to save an incident without attachments and with Category='Software'. My custom info message will be displayed as well, but why 'Invalid update' is there???
16 REPLIES 16

CapaJC
ServiceNow Employee
ServiceNow Employee

That message is hardcoded when an action has been aborted by setAbortAction(). I'm unaware of a way to not have it show.


Are you sure about that? Because I have another business rule with setAbortAction(), it works fine and there is no 'Invalid update' message:

This rule intercepts removal of approval records

Table:


sysapproval_approver

When:

Before

Delete:

Yes

Condition:

current.wf_activity==''&&current.state!='requested'&&current.state!='approved'&&current.state!='rejected'

Script:

current.comments = 'Approval record has been permanently deleted/removed from the original ticket '+current.sysapproval.number+' by '+gs.getUser().getFullName();
if (current.state=='not requested') { current.state = 'not_required'};
current.sysapproval = '';
current.update();
current.setAbortAction(true);



CapaJC
ServiceNow Employee
ServiceNow Employee

In your script example, the setAbortAction() is after the update(), so the update to the database has already happened. I don't think any message would be displayed in that case.


ravali6
Giga Contributor

May be you are missing the semicolon after the gs.addInfoMessage() method..