To hide the "Duplicate" and "Delete Demand" options from the row context menu in a ServiceNow workspace for users who are not admin or don't have the sn_align_core.apw_admin role, you generally need to customize the row context menu behavior, usually by modifying the UI Action definitions or using Client Scripts/Condition scripts that control these actions' visibility.
Since this is for a Workspace (likely the Agent Workspace or a custom Workspace), the context menu is often controlled via UI Actions or Action configurations that appear on that list/grid.
Step-by-step approach:
1. Locate the UI Actions for "Duplicate" and "Delete Demand":
- Navigate to System Definition > UI Actions.
- Search for actions with the names or labels containing
"Duplicate" or "Delete Demand" on the Demand table (e.g., sn_demand_demand or the specific table your demands reside on).
- Check the
Table field is your demand table.
In Workspace context menus, UI Actions are often marked with the List choice or Context Menu options.
2. Modify the UI Actions to add a condition restricting visibility:
Usually, a UI Action's Condition field determines who sees it. You will update this condition so that only admin or sn_align_core.apw_admin users see these actions.
Example condition you can add:
gs.hasRole('admin') || gs.hasRole('sn_align_core.apw_admin')
Remove any other conditions or append this with logical AND if needed.
3. If workspace uses a different configuration (like workspace Action configurations):
If these options come from a different Workspace Configuration (not UI Actions), you may need to customize the Workspace Actions:
- Navigate to Workspace > Action Configuration or Workspace > Row Actions.
- Find the actions corresponding to Duplicate and Delete Demand.
- Edit their Condition or Visibility scripts to restrict to those roles:
Example visibility script:
(function() {
return gs.hasRole('admin') || gs.hasRole('sn_align_core.apw_admin');
})();
Or in client-side syntax:
(function() {
var user = $sp.getUser(); // if in widget script context
return user.roles.indexOf('admin') !== -1 || user.roles.indexOf('sn_align_core.apw_admin') !== -1;
})();
4. Test the changes:
- Log in as a user without these roles and verify Duplicate and Delete Demand options do not show.
- Log in as admin or a user with the sn_align_core.apw_admin role and verify these options are visible.
Summary
| Step | Action |
|---|
| Locate UI Action or Workspace Action Configuration | System Definition > UI Actions or Workspace > Action Configuration |
| Edit Condition or Visibility rule | Add: `gs.hasRole('admin') |
| Save and test | Validate with users in and out of roles |
If you want, I can provide a sample UI Action script update example or a sample Workspace action visibility script. Just let me know!