Get the sysid of the parent record from the related list UI action button

G Balaji
Kilo Guru

HI

I need to get the sysid of the parent record on UI Action button click. UI action button is placed in one of the related list in the form.

In other words,

Record from table x is displayed on the form.

there are four other tables, A,B,C,D which has a field called Parent which refers to the sys id of the record in the table X. Now I need to get the sysid of the record in the table X on UI Action button placed in one the related list D.

Kindly tell me how to implement this?

 

Thanks

1 ACCEPTED SOLUTION

tim2222
Tera Expert

Hi,

Find the UI Actions "New" on the table "Global". These actions work on related lists and support setting the parent on the new record.

If you're creating a client side UI Action for related lists you can get the sys_id of the current record by either:

g_form.getUniqueValue();

Or via g_list:

g_list.getSubmitValue('sysparm_collection_key'); // Field name of relation
g_list.getSubmitValue('sysparm_collectionID'); // sys_id of parent

If you're creating a server side UI Action you need to parse the URL:

var uri = action.getGlideURI();
uri.get('sysparm_collection_key'); // Field name of relation
uri.get('sysparm_collectionID'); // sys_id of parent record

Tim.

View solution in original post

5 REPLIES 5

Stewe Lundin
Mega Guru

Are the parent record presented in a Reference filed ? 


 

 

 

tim2222
Tera Expert

Hi,

Find the UI Actions "New" on the table "Global". These actions work on related lists and support setting the parent on the new record.

If you're creating a client side UI Action for related lists you can get the sys_id of the current record by either:

g_form.getUniqueValue();

Or via g_list:

g_list.getSubmitValue('sysparm_collection_key'); // Field name of relation
g_list.getSubmitValue('sysparm_collectionID'); // sys_id of parent

If you're creating a server side UI Action you need to parse the URL:

var uri = action.getGlideURI();
uri.get('sysparm_collection_key'); // Field name of relation
uri.get('sysparm_collectionID'); // sys_id of parent record

Tim.

So I see that within the API documentation, g_form.getUniqueValue() is documented:

https://developer.servicenow.com/app.do#!/api_doc?v=kingston&id=r_GlideFormGetUniqueValue

and/or

https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_reference/GlideForm/concept/c_GlideFormAPI.html#r_GlideFormGetUniqueValue

 

However, and maybe I'm just missing it, but is there any developer documentation anywhere on the action object or its methods as shown in the examples above? ... action.getGlideURI() and uri.get([parameter])...

Thanks.

Having found that UI actions on lists don't support the same behaviour as those on forms ("onclick","client-side" and "server-side" as per the SNGuru) - I'm really grateful I found this post. Many thanks, Tim.