- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2017 03:06 AM
Hi
We currently redirect non-roled users to the service portal after login. We use a sys property glide.entry.loggedin.page_ess and the value /ictportal.
We would like to improve on this so a user (roled or not) is redirected to where they were going before the login. For example our corporate intranet site would like to link to a servicenow catalog item
The desired behavior is: User is browsing the corporate intranet site and clicks link to go to ServiceNow "Request Staff ID Badge" catalog item. ServiceNow will present the ADFS login page (our IdProvider), the user enters their correct credentials and they are redirected to the "Request Staff ID Badge" catalog item".
Currently this fails because after login the users is taken to the portal homepage.
The solution should allow us to create a hyperlink to any destination we desire and redirect the user to that destination (providing they have permission), whether it is a catalog item, a ticket, or a knowledge article, etc.
Regards
Craig
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2017 06:55 AM
I've got this working.
We had actually used the article that Chirag linked to, to create the redirect in the OP. But we had missed a sys property glide.entry.first.page.script.
Adding that property as per the instructions in the article has providered the desired behaviour.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2017 02:49 PM
Hi Craig,
May be below blog can be helpful :
6 ways to set up your Service Portal for redirection SUCCESS!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2017 06:55 AM
I've got this working.
We had actually used the article that Chirag linked to, to create the redirect in the OP. But we had missed a sys property glide.entry.first.page.script.
Adding that property as per the instructions in the article has providered the desired behaviour.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2018 11:40 AM
Hi Craig,
We are trying to set up this exact same functionality but we are running into issues. How did you set up your URLs so that a user clicking on a direct link to a cat item or other record gets directed to ADFS if they are not authenticated, and then once logged in gets to the item you linked? We have our cat item page non-public, and when we link to a cat item, the user is presented with the OOB ServiceNow login page, and they do not get directed to ADFS. The generic Login link in the SP header works for us, and directs the user to our ADFS login page, but when they log in that way they are redirected back to the main SP home page.
Any help you can give us would be much appreciated.
Thanks,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2018 01:51 AM
Hi Steve,
Sorry I've just noticed this comment. Have you got this working?
I had to edit/create the 3 system properties in the image below.
For glide.entry.first.page.script I pointed the Value to a copy of the original script include that I called SPEntryPage_override.
I edited this to point to our serviceportal root and commented out a getLoginURL function, that function was breaking side_door.do. There is another small change commented in the code where I:
//change the line below to point to nav_to.do
//nt = sPage;
nt = "nav_to.do";
I can't remember why that was needed. It has been awhile.
Hope that helps
/**
*
* Service Portal sample script include to indicate
* 1. which login page should be used
* 2. the starting page after the user is authenticated
*
* Script is configured using system properties
* PROPERTY VALUE
* glide.entry.page.script new SPEntryPage_override().getLoginURL();
* glide.entry.first.page.script new SPEntryPage_override().getFirstPageURL();
*
* functions can return a path or null if no overrides are necessary
*
**/
var SPEntryPage_override = Class.create();
SPEntryPage_override.prototype = {
initialize: function() {
this.logVariables = true; // for debugging
this.portal = "/ictportal/"; // The URL suffix specified in the sp_portal record
},
/***
*
* Referred to by property: glide.entry.page.script
*
**/
//Commenting out the below function to make side_door.do work
/*getLoginURL: function() {
// When requesting a page directly (eg: /problem_list.do)
// The platform session_timeout.do sets the login page to welcome.do
// Since we are handling the login, clear that value
var session = gs.getSession();
var nt = session.getProperty("nav_to");
var sPage = session.getProperty("starting_page");
if (nt == "welcome.do")
session.clearProperty("nav_to");
if (!sPage && !nt)
session.putProperty("starting_page", gs.getProperty("glide.login.home"));
// Send the user to the portal's login page
var portalGR = new GlideRecord("sp_portal");
portalGR.addQuery("url_suffix", this.portal.replace(/\//g, ""));
portalGR.addNotNullQuery("login_page");
portalGR.query();
if (portalGR.next())
return this.portal + "?id=" + portalGR.login_page.id;
// Send to the a default login page
return this.portal + "?id=login";
},*/
/***
*
* Referred to by property: glide.entry.first.page.script
*
**/
getFirstPageURL: function() {
var session = gs.getSession();
this.logProperties('before', session);
var check = session.getRoles();
// has roles and is not a Service Portal page - go to UI16
var nt = session.getProperty("nav_to");
var isServicePortalURL = new GlideSPScriptable().isServicePortalURL(nt);
var redirectURL = session.getProperty("login_redirect");
if (check && !redirectURL && !isServicePortalURL)
return;
// user may have logged in from a frame, the /login_redirect.do page will bust out of it
if (!redirectURL) {
// redirectURL is nav_to
// if nav_to == "welcome.do" then use starting_page
var sPage = session.getProperty("starting_page");
if (sPage && nt == "welcome.do")
//change the line below to point to nav_to.do
//nt = sPage;
nt = "nav_to.do";
// Avoid a redirect loop to the home page
if (nt) {
var ep = gs.getProperty("glide.login.home");
if (ep == nt)
nt = null;
}
session.putProperty("login_redirect", nt || "true");
return "/login_redirect.do?sysparm_stack=no";
}
session.clearProperty("login_redirect");
var returnUrl = this.portal;
if (redirectURL && redirectURL != "true") {
var spUrl = new GlideSPScriptable().mapUrlToSPUrl(redirectURL);
returnUrl = spUrl ? this.portal + "?" + spUrl : redirectURL;
}
this.logProperties('after', session);
if (!this.logVariables) {
gs.log('redirectURL: ' + redirectURL);
gs.log('User: ' + user.getName());
gs.log('is internal: ' + (!user.hasRoles()));
gs.log('returnUrl: ' + returnUrl);
}
return returnUrl;
},
logProperties: function(beforeOrAfter, session) {
if (!this.logVariables)
return;
gs.log('SPEntryPage_override: Redirect ------------------------------- ' + beforeOrAfter);
gs.log('session.starting_page: ' + session.getProperty("starting_page"));
gs.log('session.nav_to: ' + session.getProperty("nav_to"));
gs.log('session.login_redirect: ' + session.getProperty("login_redirect"));
gs.log('gs.fURI: ' + session.getURI());
},
type: 'SPEntryPage_override'
};