- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2020 01:10 AM
Hello,
I am having issues with gr.isActionAborted(). Even though my update does NOT go through, gr.isActionAborted() returns false. Weirdly, when logging gr.update(), it returns null... I logged it like this. This code snippet is placed within an if-statement checking that grTask.isValidRecord()
grTask.update();
gs.info("grTask: " + grTask.update());
gs.info("is action aborted?" + grTask.isActionAborted());
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2020 01:42 AM
Hi,
see image below
1) I have 1 Before BR which blocks the update
So isActionAborted() -> gave true
I deactivated the BR and
So isActionAborted() -> gave false
Regards
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-23-2020 02:04 AM
Hi,
to verify update happened with no error use this method on gliderecord object
grTask.getLastErrorMessage()
Regards
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-23-2020 02:26 AM
I did a test in background script myself. This works (querying the RITM table directly):
var gr = new GlideRecord('sc_req_item');
gr.get('122392db1b7b8c109f79975e0d4bcbc8');
if (gr.isValidRecord()) {
gr.setValue("u_billable_task","");
gr.update();
gs.info(gr.isActionAborted()); //returns true }
While this does not work (similarly to my script...)
var gr = new GlideRecord('task');
gr.get('122392db1b7b8c109f79975e0d4bcbc8');
if (gr.isValidRecord()) {
gr.setValue("u_billable_task","");
gr.update();
gs.info(gr.isActionAborted()); //returns false }
Uhm...?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2020 02:33 AM
When querying the sc_req_item directly gr.isActionAborted() actually returns false as expected... i.e. it returns as expected when I query sc_req_item directly and not task. why could that be?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2020 05:44 AM
As mentioned earlier gr.isActionAborted() only works for before BR and not for any other operation such as query etc
Let me know if I have answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
Regards
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
‎03-18-2021 07:18 AM
Try using both the checks at once
var updatedSysId = grTask.update();
var isUpdated = (grTask.isActionAborted()) ? false : (updatedSysId == null) ? false : true;
gs.info("is action performed" +isUpdated);