How to make a variable visible from a variable set for only one catalog item

Joshuu
Kilo Sage

Hello All,

How to make a variable visible from a variable set for only one catalog item.

The below checkbox is from a variable set called approval. So I want this to be visible for only one catalog item.

find_real_file.png

Please help.

Thanks,

Priya.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use this onload catalog client script which applies on variable set

1) determine the catalog item sys_id and hide it

function onLoad(){

var itemSysId = g_form.getUniqueValue(); // gives item sys_id

if(itemSysId != 'your item sysId here'){

// hide it

}

}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use this onload catalog client script which applies on variable set

1) determine the catalog item sys_id and hide it

function onLoad(){

var itemSysId = g_form.getUniqueValue(); // gives item sys_id

if(itemSysId != 'your item sysId here'){

// hide it

}

}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hello Ankur,

I have given as below. But still I can see this variable on other catalog items too. I just need it only for one catalog item.

find_real_file.png

Hi @priyarao 

Can you please replace your below script.

function onLoad(){

var itemSysId = g_form.getUniqueValue(); // give item sys_id for which variable should be available on form

if(itemSysId != 'your item sysId here'){

g_form.setDisplay('alternate_approver_check',false);

}

}

 

Replace sys_id with catalog sys_id for which this variable should be visible. For other items it will hidden.

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Thanks Anil, It is working as expected.