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

Hi,
In "Lookup Select Box" configuration for the value field you can make it sys_id then it will work.






Thanks and Regards,

Saurabh Gupta

Hi Saurabh, 

You mean use the sys_id instead of the name?

lookup.PNG

But this will return the sys_in on the list and not the name. 

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

SanjivMeher
Kilo Patron
Kilo Patron

I think you should be using an order guide and associate catalog items based on the condition it should show.


Please mark this response as correct or helpful if it assisted you with your question.