Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to redirect users based on URL for portal

RishabhK0829545
Tera Contributor

I am using "SPEntryPage" Script include to redirect users based on particular roles, now the problem is I have implemented a functionality that users with 'x' will be redirected to csp portal always. One of the widget in portal is having a ui page that is not in portal is there and is available with the click of button. Since admins and other can see internal pages, they are able to access the ui page through portal but users with 'x' roles are not able to see internal due to configuration so everytime they click that button on portal they are getting redirected back to csp home page. how can we resolve this? is there any workaround for this?
I have tried getting url from below methods, so to redirect users based on url and role but none of them are working:

1. RP.getReferringURL();

2. var session = gs.getSession();

var url = session.getUrlOnStack();

3.  gs.action.getGlideURI();

4. session.getProperty("login_redirect");

5. session.getProperty("nav_to");
 
Nothing is working giving me url before redirection is happening.
9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@RishabhK0829545 

csp portal is for consumers

how is that widget rendering the UI page?

did you ensure your x role user has access to this widget?

what's getting rendered inside that UI page via widget?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar my widget is button upon click a new page opens up in new tab with the sys_id of that record, it is having a table format data that shows up data of servicenow to users.

@RishabhK0829545 

so when user visits csp portal and clicks that button what happens?

what should happen ideally as per your expectation

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar when user clicks that button, it should get redirected to ui page which is having content in table format. Ui page is completely separate page in servicenow developed by us. Expected behavior is that it should be opened when clicked on button widget. but currently when user clicks that button, it is redirecting to csp home page because of role based redirection. I want to apply redirection based on url and role both.