How to hide suspend ,skip, cancel RITM button on sc_task table for specific catalog item without DOM manipulation in serti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2022 04:36 AM
How to hide suspend ,skip, cancel RITM button on sc_task table for specific catalog item without DOM manipulation in service now
Currently they have been hidden using below script-
var itemID = g_form.getParameter("sysparm_id");
if (itemID == g_scratchpad.salesInvoiceItemID) {
var buttons = document.getElementsByClassName("form_action_button action_context btn btn-default");
for (var i = 0; i < buttons.length; i++) {
switch (buttons[i].id) {
case "sysverb_update_and_stay":
if (g_form.getValue("assigned_to") == "" || g_form.getValue("assigned_to") != g_user.userID) {
buttons[i].hide();
} else {
buttons[i].show();
}
break;
case "ukotvassigntome":
buttons[i].show();
break;
case "uksalesledger_reassign":
buttons[i].show();
break;
case "salesinvoicecomplete":
buttons[i].show();
break;
default:
buttons[i].hide();
}
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2022 04:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2022 07:02 AM
I don't know this was developed by other developer now in health scan these are brought up so need to fix them .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2022 07:24 AM
ok ! then why dont you try building a condition on ui action and see if you stuck somewhere , we can work from there !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2022 04:17 AM
Hi Ravi,
I tried below
SalesbuttonCheck: function(sourceRec, actionName) {
var allowAction = false;
if (gs.hasRole('admin')) {
allowAction = true;
return allowAction;
}
if (!gs.getUser().isMemberOf(sourceRec.assignment_group))
return allowAction;
switch (actionName.toString()) {
case "cancel_request":
if ((sourceRec.state == 1 || sourceRec.state == 2) && sourceRec.request_item.cat_item.sys_id != gs.getProperty('salesInvoiceCatSysID')) {
allowAction = true;
}
break;
// case "suspend":
// if ((sourceRec.state == 1 || sourceRec.state == 2) && (sourceRec.request_item.cat_item.sys_id != gs.getProperty('persist.cp.item_sys_id')) {
// allowAction = true;
// }
// break;
case "skip":
if ((sourceRec.state == 1 || sourceRec.state == -5 || sourceRec.state == 2) && sourceRec.request_item.cat_item.sys_id != gs.getProperty('salesInvoiceCatSysID')) {
allowAction = true;
}
break;
}
return allowAction;
},
and then called in UI action condition but it is not working