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
‎05-04-2020 08:35 PM
Hi,
you can use the condition in business rule and check the url contains specific keyword
gs.action.getGlideURI().toString().indexOf('/sp') != -1
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2020 10:48 PM
Hi tantony,
Changes on the form are on the client side. Business rules are on the server side, they are processes after the form has been submited and the server side codes runs. So you can't handle form changes in a business rule.
On the client side you have to work with client scripts (and e.g. with ajax calls to the server side).
On the server side (business rule, after submit) you can have my code above as condition to make sure that the change is comming from the Service Portal and current.field_name.changes() to see if the field you're looking for got changed.
All the best,
Fabian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2020 03:29 PM
I could not get it work on Service Portal on my personal instance since the URI did not have the string 'api/now/sp' .
gs.addInfoMessage(gs.action.getGlideURI().toString());
Above statement displayed:
" api/now/v2/table/sys_user/6816f79cc0a8016401c5a33be04be441?api=api&sysparm_display_value=all&sysparm_fields=email"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2020 11:34 PM
HI
What do you mean with "detect"?
What is your target, you want to reach?
Just let me know.
BR
Dirk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2020 11:53 PM
Hi
Anyhow, if you want to review, what a given user is doing, you can analyze the entries in the "User Session Log" (stored in the database table "Transaction Log Entry" [syslog_transaction]).
There are entries per user "created by" and time they did that. You can review, if that happened within the same session by filtering records to the "Session" and "Session ID" columns.
The filed "Type" may be a good indicator of what happened, in combination with the column "URL".
You also may want to have a look at all currently logged in users, which you can find in the table view "Logged in User" [v_user_session].
(or by navigating to "> User Administration > Logged in users")
Let me know if that answers your question and mark my answer as correct/helpful.
BR
Dirk