Redirect user to portal based on Role.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi Team,
We have created custom scoped App along with custom portal, where we want a user who has custom_role should auto redirect to custom portal instead of native view.
we do not want to touch 'SPEntryPage' global scope script and 'glide.entry.loggedin.page_es' sys_property.
Is there any other way to achieve it making changes within custom scope App only?
Thanks In Advanced !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @DS14 ,
Create a Global Client Script in your scoped app.
Script logic:
function redirectCustomRole() { var ga = new GlideAjax('CustomRedirectUtils'); // Scoped Script Include ga.addParam('sysparm_name', 'checkRoleAndRedirect'); ga.getXMLAnswer(function(response) { if (response == 'true') { window.location = '/sp?id=custom_portal'; } }); } redirectCustomRole();Script Include CustomRedirectUtils (in your scoped app) checks role:
var CustomRedirectUtils = Class.create(); CustomRedirectUtils.prototype = { initialize: function() {}, checkRoleAndRedirect: function() { return gs.getUser().hasRole('custom_role') ? 'true' : 'false'; }, type: 'CustomRedirectUtils' };If this answer worked, please mark it as the solution. A helpful mark is also appreciated—it helps others in the community.
Thanks and Regards,
Ayush
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
@DS14 SPEntryPage and system property are the best and recommended ways to do this.
1. Global client scripts are not recommended.
2. Global UI page will land you in issues, have seen in multiple implementations.
My recommendation would be to go with SPEntryPage SI and system property.
Please mark the answer correct/helpful accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
50m ago
I will recommend updating that OOTB Script Include for your requirement
OR
you can use UI script in your scope and check which link user is navigating and what role that person has
But you will have to run that UI script on each page which is unnecessary causing performance issue.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader