Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

12 REPLIES 12

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

Hello Ankur, 

 

Based on above topic i have a below requirement ;-

 

Automatic assignment of Source = "Portal"
-- When employees report SIRs via sir.boat.com (Portal), the source should automatically be set to "Portal".

 

- Similarly if any SiR analyst raise incident from classic Ui the source should be set to backend.

 

note:- We have portal and backend choices in Source field.

 

 

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"

 

Hello Fabian, 

 

Based on above topic i have a below requirement ;-

 

Automatic assignment of Source = "Portal"
-- When employees report SIRs via sir.boat.com (Portal), the source should automatically be set to "Portal".

 

- Similarly if any SiR analyst raise incident from classic Ui the source should be set to backend.

 

note:- We have portal and backend choices in Source field.