- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2025 12:53 PM
Hi. We are trying to fix a broken Script Includes the vendor left behind. It is supposed to hide the Close button on a RITM record based on State and to hide it for 3 specific Catalog Items. It is a script include on a UI Action. Right now, it's hiding the button for all records as it seems to result in False. If I comment out just that section, it shows for all records again.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2025 10:30 AM
Hi @Ore-Jon ,
update your script include as
var HideButtonsInRITM = Class.create();
HideButtonsInRITM.prototype = {
initialize: function() {},
hideClosedButtons: function(ritmGr) {
var arr = ['43961e361badc6906ef37cd61a4bcbc4', '44188dee1b6d4a50c00fec21b24bcb94', '89df48e01b71c2d06ef37cd61a4bcbeb'];
return !arr.includes(ritmGr.getValue('cat_item'));
},
type: 'HideButtonsInRITM'
};
and UI action condition as
(current.state == 1 || current.state == 2) && new global.HideButtonsInRITM().hideClosedButtons(current);
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2025 12:55 AM
update as this and use the optimized one
I hope you are invoking it in UI action condition like this
new HideButtonsInRITM().hideClosedButtons(current.cat_item.sys_id)
var HideButtonsInRITM = Class.create();
HideButtonsInRITM.prototype = {
initialize: function() {},
hideClosedButtons: function(ritm_id) {
var sysIdArr = ['43961e361badc6906ef37cd61a4bcbc4', '44188dee1b6d4a50c00fec21b24bcb94', '89df48e01b71c2d06ef37cd61a4bcbeb']
var rec = new GlideRecord('sc_req_item');
rec.addEncodedQuery('cat_item.sys_idIN' + sysIdArr.toString());
rec.query();
return !rec.hasNext();
},
type: 'HideButtonsInRITM'
};
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
‎06-17-2025 10:18 AM
This resulted in the same, where the button is hidden for all catalog items.
The UI Condition was:
((current.state == 1 || current.state == 2) &&( new global.HideButtonsInRITM().hideClosedButtons(current.sys_id) == 'true'))
I tried your suggestion for changing both, the UI Condition and the Script include, but it's hiding the button on all RITM's.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2025 10:30 AM
Hi @Ore-Jon ,
update your script include as
var HideButtonsInRITM = Class.create();
HideButtonsInRITM.prototype = {
initialize: function() {},
hideClosedButtons: function(ritmGr) {
var arr = ['43961e361badc6906ef37cd61a4bcbc4', '44188dee1b6d4a50c00fec21b24bcb94', '89df48e01b71c2d06ef37cd61a4bcbeb'];
return !arr.includes(ritmGr.getValue('cat_item'));
},
type: 'HideButtonsInRITM'
};
and UI action condition as
(current.state == 1 || current.state == 2) && new global.HideButtonsInRITM().hideClosedButtons(current);
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2025 10:46 AM
Hi @Ore-Jon
update your script include as
var HideButtonsInRITM = Class.create();
HideButtonsInRITM.prototype = {
initialize: function() {},
hideClosedButtons: function(ritmGr) {
var arr = ['43961e361badc6906ef37cd61a4bcbc4', '44188dee1b6d4a50c00fec21b24bcb94', '89df48e01b71c2d06ef37cd61a4bcbeb'];
return !arr.includes(ritmGr.getValue('cat_item'));
},
type: 'HideButtonsInRITM'
};
and UI action condition as
(current.state == 1 || current.state == 2) && new global.HideButtonsInRITM().hideClosedButtons(current);
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya