SetAbortAction is not working in BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2024 11:24 PM
I'm using this br but setabortaction is not working as it shows invalid update but shows the error message
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('incident');
gr.addQuery('state','!=','7').addCondition('parent_incident',current.sys_id);
gr.query();
if(gr.hasNext()){
gs.addErrorMessage("Please close child incidents.");
current.setAbortAction(true);
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2024 11:37 PM
Hi @nowitsvashu please use like below and avoid using gr
var inc = new GlideRecord('incident');
inc.addQuery('parent_incident',current.sys_id);
inc.addQuery('state','!=','7');
inc.query();
if(inc.hasNext()){
gs.addErrorMessage("Please close child incidents.");
current.setAbortAction(true);
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2024 11:41 PM
Thankyou for your reply @Harish KM .
I used your script but its again showing the same error "invalid update" and setabortaction still not working.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2024 11:47 PM - edited ‎03-05-2024 11:48 PM
Hi @nowitsvashu that's fine you get this message invalid update because of the setAbortAction, this mean the record did not update successfully which works as required
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2024 11:59 PM
Hi @nowitsvashu there could be more than 1 child incidents, so use while loop instead of if condition
var inc = new GlideRecord('incident');
inc.addQuery('parent_incident',current.sys_id);
inc.addQuery('state','!=','7');
inc.query();
while(inc.hasNext()){
gs.addErrorMessage("Please close child incidents.");
current.setAbortAction(true);
}
Harish