Is it possible to hide a variable like "Address" from a catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2025 01:30 AM - edited 05-15-2025 01:31 AM
Is it possible to hide a variable like "Address" from a catalog item in ServiceNow once the request is fulfilled. Untill the RITM Is fulfilled variable should be visible, once it's fulfilled variable value or variable with value should be hide.
Example :
Catalogue ITEM : ABC
Variable : Address
I tried with Catalouge UI policy and UI Policy both not supporting. I tried with below Script inlcude and catalogue client script not working please help me on this.
Catalogue Client script :
function onLoad() {
var ritmID = g_form.getParameter('sysparm_id');
if (ritmID) {
var ga = new GlideAjax('RITMStateCheck');
ga.addParam('sysparm_name', 'getRITMState');
ga.addParam('sysparm_ritm_id', ritmID);
ga.getXMLAnswer(function(answer) {
if (answer == '6') { // 6 = Fulfilled
g_form.setDisplay('address_1', false); // 'address_1' is the variable name
}
});
}
}
Script include :
// Name: RITMStateCheck
// Accessible from: Client Callable
var RITMStateCheck = Class.create();
RITMStateCheck.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getRITMState: function() {
var ritmID = this.getParameter('sysparm_ritm_id');
var gr = new GlideRecord('sc_req_item');
if (gr.get(ritmID)) {
return gr.state.toString(); // Returns state as string (6 for Fulfilled)
}
return '';
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2025 07:58 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader