Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to trigger one specific catalog item?

Jessica28
Tera Guru

Hello,

I have an onChange type client script that reload the form after updated. I need help with the script to trigger only one catalog item.  Thanks

 

Jessica28_0-1713916022002.png

 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @Jessica28 ,

You want this script(which you attached) to only trigger for one specific catalog?
If yes, then you can modify it like this-

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

var catalogItemSysId = 'your_catalog_item_sys_id_here'; // Replace 'your_catalog_item_sys_id_here' with the sys_id of your catalog item
var currentCatalogItemSysId = g_form.getValue('cat_item'); 

if (currentCatalogItemSysId === catalogItemSysId) {
// Add your condition here, if needed

location.reload(); // Reload the form
}
}

 

Please mark as Accepted Solution if this solves your query .

 

View solution in original post

6 REPLIES 6

Community Alums
Not applicable

Hi @Jessica28 ,

You want this script(which you attached) to only trigger for one specific catalog?
If yes, then you can modify it like this-

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

var catalogItemSysId = 'your_catalog_item_sys_id_here'; // Replace 'your_catalog_item_sys_id_here' with the sys_id of your catalog item
var currentCatalogItemSysId = g_form.getValue('cat_item'); 

if (currentCatalogItemSysId === catalogItemSysId) {
// Add your condition here, if needed

location.reload(); // Reload the form
}
}

 

Please mark as Accepted Solution if this solves your query .

 

James-B
Kilo Sage

Hi Jessica, 

 

I know you have had your answer but could I ask what the use case is here please? 

 

Just being nosey.