After changing the url suffix user is still able to login to Native UI

SNOW46
Tera Contributor

Hi All,

Currently we are using MSP Instance where multiple clients are on-boarded based on domains.

For all the domains we have configured Service Portal and specified the domain separated condition in the Script Include "SPEntryPage". 

Now I have changed the suffix of one of the service portal and all the dependencies whichever we have configured.

But now I am facing a issue like if any user has saved the serviceportal url in favourites or book marks to directly login it is navigating to Native UI instead of new url suffix service portal page.

find_real_file.png

find_real_file.png

Currently it is set as any itil user or end user when they will login will redirect to Service Portal page after which only ITIL users can redirect back to Native UI by clicking on one of the Header Menu Link.

Can anyone let me know how to fix this issue? That whenever any user directly clicks on the old suffix service portal link(https://myinstance.service-now.com/sp_abc) it will be redirected back to main login page. After the user provides the credentials then user will navigate to New URL Suffix Service Portal link.(https://myinstance.service-now.com/sp_xyz)

 

 

Thanks in Advance..

6 REPLIES 6

Tony Chatfield1
Kilo Patron

Hi,

There are a couple of example UI scripts floating about, but I believe that you will find the example code is incorrect (IE references to server side functions);

Also before trying anything of this nature I would ensure you have a portal type url for the script form - so you can set it to inactive if the script doesn’t work as expected.

  • Maybe also spin up a dev instance just for testing, in case you can’t recover.

I think you need a glideajax call returning something that identifies your users in a way that can be mapped to the portal(s), role or perhaps a company or group record.

This is the basic syntax and I am still not sure this is the appropriate way to do this;
But I think it will keep your portal users away from your native U, although I don’t think it will prevent users from bouncing between portals via direct navigation.

Be interested to hear how you get on

Regards Tony

 

function portal_redirect()

{

                var location = window.top.location.toString();
                var myPortal = '';

                var userCheck = new GlideAjax('yourAjaxScript');
                userCheck.addParam('sysparm_name', 'yourAjaxFunction');
                userCheck.getXMLWait();

                var myResult = userCheck.getAnswer();

               if(myResult  == users who have instance access)    {

                                return;// users who have instance\native ui access
                }

                else if(myResult  == users who have portalA)  {

                                myPortal = '/portalA';

                }

                else  {

                                myPortal = '/portalB'; // If there is more than 1 portal.........

                }

               

// the portal identifier must appear in the url, if not then the user is redirected to the portal.

                if(location.indexOf(myPortal) < 0 )

                                {

                                window.top.location = myPortal;

                }      

}

portal_redirect();

Hi Tony,

Can you please let me know like where do I need to add the above script mentioned by you?

I am bit confused in this and new to Portal as well.

 

Thanks

Tony Chatfield1
Kilo Patron

Hi,

The code above is for a UI Script /sys_ui_script_list.do?
and the Ajax script would be a script include.

You could try g_form or gs type functions instead of the GlideAjax in the UI Script, but I had no luck with either during my tests.
As mentioned earlier when testing be careful as until you have a working query\function you cannot exclude anyone from impact of the script and can easily find that you are redirected to the portal url anytime you try to access the instance (to update this script).

Re reading your question,
I don't believe that this script will stop a user from accessing another portal directly,
but if they try direct access to an instance url it will redirect them to their defined portal homepage (although the instance window may partially load before the redirect kicks in).

Regards Tony

Hi Tony,

As I am not that pretty good in Scripting, if you can help me in building up the Configuration and setup it will be good.

Can you post some screenshots so that I can able to configure it in the same way.

 

Thanks..