Redirect Approvers Based on Role (Workspace vs ESC)
New article articles in ServiceNow Community
·
Mar 22, 2026
·
article
Redirect Approvers Based on Role (Workspace vs ESC)
Description
In some scenarios, approvers receive email notifications with links to review approvals. However, based on their roles, users should be redirected to different interfaces.
Users with the ITIL role should be directed to Agent Workspace , while users without this role should be redirected to the Employee Service Center (ESC) To-Do page.
This solution ensures a better user experience by guiding users to the correct interface based on their access level.
Steps to Implement
Create or update an Email Notification
Add a Mail Script
Use a role check to determine if the approver has the ITIL role
Generate a dynamic link based on the role
Print the link in the email template
Email Script
`(function runMailScript(
current,
template,
email,
email_action,
event
) {
var isAgent = false;
// Check if approver has ITIL role
var roleGR = new GlideRecord('sys_user_has_role');
roleGR.addQuery('user', current.approver);
roleGR.addQuery('role.name', 'itil');
roleGR.query();
if (roleGR.hasNext()) {
isAgent = true;
}
var baseUrl = gs.getProperty('glide.servlet.uri');
var link;
// Redirect logic
if (isAgent) {
link = baseUrl + 'now/cwf/agent/record/sysapproval_approver/' + current.sys_id;
} else {
link = baseUrl + 'esc?id=hrm_todos_page';
}
template.print('<a href="' + link + '" style="color:#12086f;">View Approval</a>');
})(current, template, email, email_action, event);
`
How It Works
The script queries
sys_user_has_roleto check if the approver has the ITIL roleIf true → user is redirected to Agent Workspace
If false → user is redirected to ESC portal (To-Do page)
The link is dynamically generated using the instance base URL
Result
ITIL Users → Open approval directly in Workspace
Non-ITIL Users → Open approval in ESC (Portal)
Single notification works for both user types
Conclusion
This approach provides a clean and efficient way to handle role-based redirection in email notifications , ensuring that users always land in the correct interface for their role.
https://www.servicenow.com/community/itsm-articles/redirect-approvers-based-on-role-workspace-vs-esc/ta-p/3512390