- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 01:53 AM
Hello,
I need some advise and help please.
We are using a variable set which sets variables for multiple catalog items / record producers.
This variable set is included in many items, and the variable set calls script includes to check logic and show fields accordingly.
We have a requirement to hide some of the options from a few catalog items, without affecting the others.
What is best way I can hide some fields on certain catalog items please?
have tried using UI policies on the actual catalog items that need hiding but that does not work.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 01:55 AM
Hi,
something like this
onLoad catalog client script which Applies on Variable Set
function onLoad(){
var itemSysId = g_form.getUniqueValue();
if(itemSysId == 'your Catalog item SysId'){
// hide variables with that variable set one by one
}
}
If you are thinking hard-coding is not best practice then use onLoad client script + GlideAjax and within that ajax function use getProperty() to get catalog item sysId and then compare and return true/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
‎08-11-2022 03:19 AM
Hi,
then do this
var HRCaseOptionsSupressOptions = Class.create();
HRCaseOptionsSupressOptions.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getItemsToHideOptions: function() {
var catItemSysId = this.getParameter('sysparm_itemSysId');
if(gs.getProperty('sn_hr_sp.HideItemsForHrCaseoptions').indexOf(catItemSysId) > -1)
return true;
else
return false;
},
type: 'HRCaseOptionsSupressOptions'
});
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
‎08-11-2022 03:33 AM
Thanks
In the ESC the fields are not hiding, but the alerts are appearing in both UIs
UI type for client script is set to All
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 03:58 AM
Hi,
Glad to know that my script worked.
g_form.getUniqueValue() should give you catalog item sysId in both Native + Portal
What comes in alert for g_form.getUniqueValue() in Native?
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
‎08-11-2022 04:11 AM
Thanks
all the alerts are working. I am getting different sys ids for both native and portal, but both are matching the sys id in URL so the script is working fine.
It's just not hiding it in portal but hiding in native.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 04:17 AM
Hi,
so the logic is working fine.
it's not hiding in portal means is there any other script which is running in portal which is doing the opposite.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader