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

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

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

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"

DirkRedeker
Mega Sage

HI

What do you mean with "detect"?

What is your target, you want to reach?

Just let me know.

BR

Dirk

DirkRedeker
Mega Sage

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