In many organizations, HR Employee Relations (ER) cases are created and fulfilled exclusively by the HR team. Out-of-the-box (OOB), when an agent creates a case in ServiceNow and navigates to the ER Case, the default view shown is the self-service view. This view renders everything as read-only, which prevents the agent from effectively working on the case.
To address this issue, I implemented a solution by adjusting the view rules to allow agents to access and work on the cases appropriately. Below, I share the approach and the code used to achieve this.
Default View for Grievance Cases
The following script overrides the default view for grievance cases, allowing agents with the sn_hr_er.case_writer role to access the appropriate view:
Ensuring Non-ER Employees See Only the ESS View
To ensure that non-ER employees only see the Employee Self-Service (ESS) view, the following script is used:
Explanation of the Scripts
Default View for Grievance Cases:
- This script checks if the view is not
sp(self-service) oresc(employee center), the case is not in a list, and a validsys_idis present. - It then retrieves the HR service value for the case.
- If the agent has the
sn_hr_er.case_writerrole and the HR service matches specific grievance case IDs, the view is set to "default".
- This script checks if the view is not
Non-ER Employees Only See ESS View:
- This script checks if the user does not have the
sn_hr_er.case_readerrole and if the view is notsp. - If both conditions are met, the view is set to "ess" (Employee Self-Service).
- This script checks if the user does not have the
By implementing these scripts, we ensure that agents can efficiently work on HR ER cases while maintaining appropriate access controls for non-ER employees.
Feel free to reach out if you have any questions or need further clarification.