We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Issues with gr.isActionAborted()

kyrresc
Tera Expert

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());
1 ACCEPTED SOLUTION

Hi,

see image below

1) I have 1 Before BR which blocks the update

So isActionAborted() -> gave true

find_real_file.png

find_real_file.png

I deactivated the BR and

So isActionAborted() -> gave false

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

14 REPLIES 14

Hi,

to verify update happened with no error use this method on gliderecord object

grTask.getLastErrorMessage()

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

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...? 

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?

@kyrresc 

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

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Kurian Thomas P
ServiceNow Employee

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);