Can anyone please correct my code.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 06:53 AM
I want to hide the 'Delete' button for users with the 'itil_agent_l1', 'itil_l2', 'itil_agent_l1', 'itil_l2' roles, when they are in the Workspace view. Below is my code. But it's not working.
function onLoad() {
var userRole = g_user.hasRoleFromList('itil_agent_l1', 'itil_l2', 'itil_agent_l1', 'itil_l2');
var uiActionName = g_ui_actions.getByName('sysverb_delete');
alert("Hi "+ uiActionName);
if(userRole && g_form.getViewName() == 'workspace') {
uiActionName.setVisible(false);
}
}
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 10:07 AM
I assume your alert is giving you the expected uiActionName? Have you added an alert inside the if block to confirm that both conditions are met? Once you can get inside the if, try this code instead, ensuring that the isolate script box remains unchecked. This DOM manipulation might not work in the Workspace
$$('button[data-action-name^=sysverb_delete]').each(function(e) {
if(userRole && g_form.getViewName() == 'workspace')
e.hide();
});
The alternative is to add the role and view name checks to the condition field on the UI Action record.