UI Action script is unable to read the sys_id of incident

Ketan Pandey
Tera Expert

I have created a UI Action on incident table .in UI Action Script i have written the below

 

 

var incident_sysid=g_form.getValue('sys_id');

alert(incident_sysid);

it returning null value

7 REPLIES 7

Daniel Borkowi1
Mega Sage

Hi @Ketan Pandey, g_form.getValue() can only deliver fields which are visible on form. Sys_id isn't. Try g_form.getUniqueValue() instead. Check the API here: https://docs.servicenow.com/en-US/bundle/vancouver-api-reference/page/app-store/dev_portal/API_refer....

 

Greets
Daniel

Please mark reply as Helpful/Correct, if applicable. Thanks!

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Ketan Pandey ,

 

While creating UI action check the client as true 

GunjanKiratkar_1-1693204603923.png

 

Include your client code in function and call that function onclick as below and use g_form.getUniqueValue():

 

GunjanKiratkar_0-1693204580088.png

function doSubmit(){
var incident_sysid=g_form.getUniqueValue();
alert(incident_sysid);
}

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Ketan Pandey
Tera Expert

How to get the referance field value,please suggest

What you exactly want only the value(i.e, sys_id) or display value of the field