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
05-15-2025 01:47 AM - edited 05-15-2025 02:17 AM
Hi @B Ashok ,
Correct Approach for Hiding Variables on RITM form
You should use a UI Policy on the sc_req_item table, scoped to the variable, and use a GlideRecord script condition to detect state.
Goal:
Hide the variable from RITM view if the request is in Fulfilled (state = 6).
Solution
1. Create a Catalog UI Policy
Table: sc_req_item
Run on Load: ✅ (checked)
Global: ✅ if needed
Conditions: None (we’ll use script condition)
2. Add a Script Condition
Under the "Advanced" checkbox in the UI Policy, use this:
3. UI Policy Action
Variable name: address_1
Visible: ❌ (unchecked)
This ensures the variable is hidden only when the RITM is Fulfilled.
Optional: Use a Client Script on sc_req_item (Not preferred)
If you still want to use a client script, it must be a standard UI script (not catalog client script), and only runs in the RITM form context:
Use 'variables.<variable_name>' to refer to catalog variables on the RITM form.
Please mark it as helpful. solution is fine.
thanks
Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2025 02:14 AM
you can use normal client script onLoad of RITM table, don't use catalog client script
function onLoad() {
// use correct state value to compare
if (g_form.getValue('state').toString() == '6') {
g_form.setDisplay('variables.address_1', false);
}
}
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2025 09:26 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2025 01:47 AM
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