catalog item sys id

servicenow14710
Tera Expert

Hello developers, how to get catalog item sys id in on change client script which i need to use in script include.

I tried using : var catSysId = g_form.getParameter("sysparm_id");

but gives error
g_form.getParameter is not a function.

Any help is appreciated. Thanks!

5 REPLIES 5

Ethan Davies
Mega Sage
Mega Sage

You can use the code below.

g_form.getSysId();


// Show the item sys_id as an Info Message
g_form.addInfoMessage(g_form.getSysId());

Hello @servicenow14710 ,

You can use g_form.getUniqueValue(); to get catalog item sys id.

 

Regards,

Rohini Sane

AshishKM
Kilo Patron
Kilo Patron

Hi @servicenow14710 

Use g_form.getUniqueValue(), which will return the sys_id of the catalog item.

 

g_form.getUniqueValue();

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

swathisarang98
Giga Sage
Giga Sage

Hi @servicenow14710 ,

 

If you are trying to pass sys id from client script to script include use below code,

var catSysId = this.getParameter("sysparm_id");

 

If in client script if you are trying to get sysid,

var sysid = g_form.getUniqueValue();

gr.addParm("syspram", sysid);

 

if in client script if you are trying to get sys id of reference field then try ,

var sysid_field = g_form.getValue ('Field backend name');

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang