Catalog Client Script - OnChange

Edxavier Robert
Mega Sage

Looking for some help or directions with my issue. I have a catalog item request where one of the variables is a reference field to the maintain item list. I am looking to re-direct the user to the specific item after they make the selection. I can make it happen if I hard code the link but I wanted to create a dynamic link that capture the correct sys_id of the selection. 

 

I have created an onChange catalog client script to check when the field change. 

var SysId =  g_form.getValue('software_items'); //name of the variable

if (newValue !== 'none') {
var url = https://dev69851.service-now.com/sp?id=sc_cat_item&sys_id=' + SysId + '&sysparm_category=69d0e41b1b5f8150a190ece0f54bcb4e',
_blank;
top.window.open(url, "_blank");
}
}

where it says I need the sys_id of the selection

 

EdxavierRobert_0-1670004994554.png

 

Any help will be appreciated it. 

1 ACCEPTED SOLUTION

You can use the name in label field and if need it at client end use g_form.getDisplayValue('var_name'); 


Thanks and Regards,

Saurabh Gupta

View solution in original post

8 REPLIES 8

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,
Try below code

var SysId =  g_form.getValue('software_items'); //name of the variable
if (newValue) {
var url = https://dev69851.service-now.com/sp?id=sc_cat_item&sys_id=' + SysId;
top.window.open(url, "_blank");
}



 


Thanks and Regards,

Saurabh Gupta

Hi Saurabh, 

Thanks for you reply, but the issue is that is not returning the sys_id instead is getting the name of the value

name.PNG

But the same code on my PDI is returning the sys_id

sys_id - pdi.PNG

Hi,
Can you please check the type of the variable and give the screenshot?



Thanks and Regards,

Saurabh Gupta

Hi Saurabh, 

The variable type is Lookup Select Box, but on my PDI is a reference. I think that's the issue.