- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2018 01:36 PM
HI,
I have a BR which runs on CHG table and prevents a CHG record to get updated its state if that CHG's tasks are open. The BR also throws an error message stating the same. See below code which runs fine.
I am working on another script (for example, script name: ABC) where also I need to update CHG record, and during the update the above mentioned BR executes and the update does not happen. Now, I want to show the message - "Please close all the change tasks before making the change request as review" which is coming from the above mentioned BR in my script ABC.
Is there any way that I can show the error messages that are coming from a BR? Please help.
Thank you, Sudi
(function executeRule(current, previous /*null when async*/) {
var v_grChg = new GlideRecord('change_task');
v_grChg.addQuery('change_request', current.sys_id);
v_grChg.addQuery('state', '!=', '3'); // Closed Complete
v_grChg.query();
if (v_grChg.next()) {
gs.addErrorMessage("Please close all the change tasks before making the change request as review.");
current.setAbortAction(true);
}
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2018 03:04 AM
Hi Sudipta,
So this is how you would get last error message while record insert/update happens
grObject is the glide record object of the record
var errorMessage = grObject.getLastErrorMessage();
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2018 10:28 AM
Thank you, it worked. 🙂