Detect user working in UI or Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2018 02:09 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2018 03:01 PM
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=
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2018 08:02 AM
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!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2018 01:18 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2020 04:24 PM
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