logo

NJP

Restrict Resource Manager to Confirm/Allocate/Reject his Group/Users

Import · Jun 09, 2022 · article

While working on a specific project, we had a requirement where resource managers should be able to confirm/allocate/reject only groups/users that they directly manage. I was surprised to not find anything on this matter, so I wanted to provide a solid solution.

To fully describe the requirement, we have to restrict the Resource Manager's ability to do CAR (Confirm/Allocate/Reject) actions - either this is from a resource plan record or from his Allocation Workbench.

image

This can be achieved by editing the Script Include called RMUIActionHelper:

image

The following functions determine the conditions for the CAR actions that are available to every user:

canConfirm: function() {
        return gs.hasRole('resource_manager') && (this.gr.state == ResourcePlanState.REQUESTED) && this.gr.getValue('plan_type') != 'operational_work';
},

canConfirmAndAllocate: function() {
    return gs.hasRole('resource_manager') && (this.gr.state == ResourcePlanState.REQUESTED) && this.gr.getValue('plan_type') != 'operational_work';
},

canAllocate: function() {
    return gs.hasRole('resource_manager') && (this.gr.state == ResourcePlanState.CONFIRMED || (this.gr.state == ResourcePlanState.ALLOCATION_IN_PROGRESS && this._allocationEventFailed()) || (this.gr.state == ResourcePlanState.REQUESTED && this.gr.getValue('plan_type') == 'operational_work'));
},

canReject: function() {
    return gs.hasRole('resource_manager') && (this.gr.state == ResourcePlanState.REQUESTED) && this.gr.getValue('plan_type') != 'operational_work';
},

By simply appending the condition "&& (this.gr.group_resource.manager.getValue()gs.getUserID() || this.gr.user_resource.manager.getValue()gs.getUserID())" at the end of each of the existing conditions we are effectively restricting the CAR actions to the resource managers that are managers of groups/users on the resource plan specified:

canConfirm: function() {
    return gs.hasRole('resource_manager') && (this.gr.state == ResourcePlanState.REQUESTED) && this.gr.getValue('plan_type') != 'operational_work' && (this.gr.group_resource.manager.getValue()==gs.getUserID() || this.gr.user_resource.manager.getValue()==gs.getUserID());
},

canConfirmAndAllocate: function() {
    return gs.hasRole('resource_manager') && (this.gr.state == ResourcePlanState.REQUESTED) && this.gr.getValue('plan_type') != 'operational_work' && (this.gr.group_resource.manager.getValue()==gs.getUserID() || this.gr.user_resource.manager.getValue()==gs.getUserID());
},

canAllocate: function() {
    return gs.hasRole('resource_manager') && (this.gr.state == ResourcePlanState.CONFIRMED || (this.gr.state == ResourcePlanState.ALLOCATION_IN_PROGRESS && this._allocationEventFailed()) || (this.gr.state == ResourcePlanState.REQUESTED && this.gr.getValue('plan_type') == 'operational_work')) && (this.gr.group_resource.manager.getValue()==gs.getUserID() || this.gr.user_resource.manager.getValue()==gs.getUserID());
},

canReject: function() {
    return gs.hasRole('resource_manager') && (this.gr.state == ResourcePlanState.REQUESTED) && this.gr.getValue('plan_type') != 'operational_work' && (this.gr.group_resource.manager.getValue()==gs.getUserID() || this.gr.user_resource.manager.getValue()==gs.getUserID());
},

Have in mind that this change only affects the CAR actions. The resource managers that are not direct managers of the User/Group, still have visibility on these resource plans.

If this article helped you, please mark it as helpful.

View original source

https://www.servicenow.com/community/spm-articles/restrict-resource-manager-to-confirm-allocate-reject-his-group/ta-p/2301450