- 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-17-2018 01:40 PM
Where are you running the script ABC? On which table? When do you want to show the error message
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2018 02:53 AM
It's from a Scripted WebService, which tries to update record on Change table. I want to show the error message from BR in that Scripted WS. Let me know if that helps you.
Thank you!
- 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 09:36 AM
Let me try and will let you know. Thanks!