The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How do I restrict the Resource Assignment toggle in Project Workspace to only a specific role?

dpattersonryder
Tera Contributor

Hi Everyone,

I'm working in the ServiceNow Xanadu Build, customizing the Project Workspace (SPM) Experience.  Specifically, I need to restrict visibility of the Resource Assignment Toggle in the planning workspace.  

My Goal:
Only users with either the it_pps_admin or our new resource_user_pilot roles should see the Resource Assignment Toggle/Button in the Planning view.

What I've tried so Far:
Client Scripts that set state.showResourceToggle based on user roles and bind that to the toggle's "Hide component" property. 
DOM manipulation (e.g., using queryselector to hide the toggle after page load).
Modify classicConsoleURLsJSON output in an onDataChanged script to filter out the resource pane. 
UI Scripts with role checks, g_user.hasrole, etc.

Despite these, the toggle still renders or fails to bind properly in the UI Builder.

What I need to know:

Is there a supported way to control visibility of the Resource Assignment Toggle (or Pane) in the Project Workspace using role-based logic?
Can the Planning UX Page or its macroponent be overridden cleanly?
Has anyone successfully scoped visibility for that toggle using macroponent overrides, UI Builder conditionals, or a clean UXF pattern?

Appreciate any guidance or best practices! I want to do this the right way, not with a fragile DOM patch. 

Thanks, 
Devon Patterson

1 ACCEPTED SOLUTION

Nootan Bhat
Kilo Sage

Hi @dpattersonryder ,

In the script include "ProjectWorkspaceConfig" there is a function getConfig, which return the Config properties for PW. 
you can modify the property value isRPEnabled: ProjectWorkspaceUtil.isResourcePlanningEnabled() to 

isRPEnabled: ProjectWorkspaceUtil.isResourcePlanningEnabled() && (gs.hasRole("ROLE_NAME")),

This way you can control the access without modifying the UI builder elements.

 

If this helps, please mark my answer as Accepted solution.

 

Hope it helps!

Nootan 

 

View solution in original post

6 REPLIES 6

HidekiOgawa
Tera Guru

Please try the following script.

function evaluateProperty({api, helpers}) {
  const roles = api.context.session.user.roles;
  return !(roles.includes('it_pps_admin') || roles.includes('resource_user_pilot'));
}

スクリーンショット 2025-06-18 17.05.03.png

 

If the panel is displayed, you also need to add a condition to "Displays Resource Panel".
The client state parameter "isResourcePlanOn" is saved in sys_user_preference when you toggle it on/off. (sn_pw_display_resource_panel)

スクリーンショット 2025-06-18 17.07.24.png

dpattersonryder
Tera Contributor

Thank you, I will give this a shot today. I will let you know.

Nootan Bhat
Kilo Sage

Hi @dpattersonryder ,

In the script include "ProjectWorkspaceConfig" there is a function getConfig, which return the Config properties for PW. 
you can modify the property value isRPEnabled: ProjectWorkspaceUtil.isResourcePlanningEnabled() to 

isRPEnabled: ProjectWorkspaceUtil.isResourcePlanningEnabled() && (gs.hasRole("ROLE_NAME")),

This way you can control the access without modifying the UI builder elements.

 

If this helps, please mark my answer as Accepted solution.

 

Hope it helps!

Nootan 

 

This was the fastest way to get this done and it completely works. The only thing I changed to the code was:

isRPEnabled: ProjectWorkspaceUtil.isResourcePlanningEnabled() &&

                (gs.hasRole("resource_user_pilot") || gs.hasRole("resource_manager_pilot") || gs.hasRole("it_pps_admin")),

 

Which made it work flawless. Thank you!