Detect user working in UI or Service Portal

Stijn Verhulst3
Kilo Guru

Hi everyone,

does anyone know whether it's possible to detect whenever a user is switching between the classic UI and the Service Portal (not login & logout)?

Kind regards,

Stijn

9 REPLIES 9

adamjgreenberg
ServiceNow Employee
ServiceNow Employee

You would have to monitor the URL.




Classic IU = yourinstance.service-now.com/nav_to.do?uri=/home.do%3F



Service Portal from within UI = yourinstance.service-now.com/sp?sysparm_stack=no




You should be able to monitor the URL changes OR you can run a cursory review on syslog_transactions where URL starts with /$sp.do




yourinstance.service-now.com/syslog_transaction_list.do?sysparm_query=sys_created_onONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)%5EurlSTARTSWITH/%24sp.do&sysparm_first_row=1&sysparm_view=


Hi Adam,



thanks for your reply. Problem is however I have no idea of how to monitor the URL, as I've tried mutliple options like UI Scripts, Business Rules on the Transaction Log table (not possible so it seems and somehow makes sense), etc...



If I'd be able to somehow "catch" the moment when someone is navigating to UI16 and before the latter being loaded, that would be great!


Fabian10
Tera Guru

Hi Stijn

Not sure if your question's still important, but probably it could be interesting for others. I figured out that you could use the following code from server side to check if the user is loading the Service Portal or the backend:

gs.action.getGlideURI().toString().startsWith('api/now/sp') ==> will return true or false (true means it's running from Service Portal)

With this solution you're independent from the URL and from the Service Portal which is loading (you could probably have multiple Service Portals).

Please mark as answer and helpful if it helps.

Regards,

Fabian

Fabian,

I need to run a business rule only if user is changing the form on Service Portal. Otherwise a client script takes care of it.How to determine if user is changing the form from service portal in a business rule?

Thanks