Current object not accessible from Action Item Script

JP22
Mega Guru

I'm trying to replicate a UI action from ServiceNow self-service into the ServiceNow Agent mobile app.

I created a function in studio (context: Record) to call an action item (use current record as condition is true) which is of type: Script. 

I copied the script from UI Action to the script in the action item.

I already added this action into the footer function of the Applet.

 

The script's purpose is to:

1- Update the current record

2- Update the parent record 

 

The button appears correctly with the given conditions of the current record, but when i trigger the script by clicking the button, this error appears:

find_real_file.png

 

Seems like the current object is not accessible, but it is available on the right side selection:

find_real_file.png

 

Can anyone guide me about this problem?

Thank you so much!

 

1 ACCEPTED SOLUTION

JP22
Mega Guru

Update:
I was able to make this work by passing the sys_id in input and then using a GlideRecord to access the fields I want.

View solution in original post

4 REPLIES 4

Mike Patel
Tera Sage

instead of

current.parent

try

input.parent

and make sure you have parent as Item parameter

Hi Mike,

Thanks for your answer. However, I still need to access the current object (the record where I clicked the button) as I will do a current.update() in the script

JP22
Mega Guru

Update:
I was able to make this work by passing the sys_id in input and then using a GlideRecord to access the fields I want.

SourinPari
Tera Contributor

Hi JP22,

 

How you are passing the sys_id here, can you explain.

 

Thanks,

Sourin