- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2021 02:56 AM
Hello Community,
Can anyone help us.
We have variable set with few variables and we are this variable set for couple of catalog items,
Our case we want hide particular variable in one catalog item how to do this tried with catalog client script onload and ui policy and it's not working still visible in portal Can anyone help us with solution for this
Please note this variable is mandatory in variable set
Thanks,
Nagesh
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2021 03:25 AM
Hey! Using a catalog ui policy should be the easiest solution. Set the catalog ui policy to apply on the specific catalog item, build your condition (leave empty if it should always apply) and then use an UI policy action where you set the variable from the variable set to Mandatory -> false and Visible -> false. The other attributes can stay with "Leave alone".
This should work in Service Portal as well.
The UI policy action could look like this: (Standard Employee Questions is the variable set in this example)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2021 03:01 AM
this should work fine
1) onLoad Catalog Client Script which Applies to Variable Set
2) UI Type - ALL
3) Script below
Ensure you add valid catalog item sys_id in below
function onLoad(){
if(g_form.getUniqueValue() == 'Your Catalog Item SysId Here'){
g_form.setMandatory('variable1', false);
g_form.setVisible('variable1', false);
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2021 03:07 AM
In Portal it's still visible
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2021 03:19 AM
Hi,
for portal also g_form.getUniqueValue() should give your item sys_id
Did you set UI type - ALL?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2021 03:21 AM
Yes ankur set as UI type all