How can I populate current catalog item name inside a variable of same catalog item?

shrija10
Kilo Contributor

Hi,

I have created a variable inside a particular catalog item ie. Software name. I want to auto populate the name of my current catalog item in "Software name" variable. Is there any way to populate name of current catalog item in Software name???

find_real_file.png

5 REPLIES 5

HarshTimes
Tera Guru

use code   - javascript:current.cat_item in default value of name field


Mihir Mohanta
Kilo Sage

Write an on load client script:



function onLoad() {


    //Type appropriate comment here, and begin script below


    var item = g_form.getParameter("sysparm_id");


g_form.setValue('your variable name goes here',item);


}



In place of bold text write the variable name of 'Name' variable.




Thanks,


Mihir


Ajai S Nair
Giga Guru

Hi Shrija,



Since Name field is a reference you can assign the SYS_id of the current item by using the below script in an onload catalog client script


var sysId = gel('sysparm_id').value;


Then set this value to your name field.


g_form.setValue('fieldname',sysId);



Or


with g_form.getParameter('sysparm_id') in a client script you can get the sys_id of the catalog item


Or


var Sysid = g_form.getUniqueValue();



Refer the links below for details:


Dot walking in client script for catalog item


Unique Record Identifier - ServiceNow Wiki


Teddy1
Kilo Contributor

I know this is an old post but I run into the same issue today and resolved it successfully by creating a workflow run script and put current.cat_item.sys_name. I hope this will save some time.