Disable accessing serviceportal in mobile browser

guestee
Tera Contributor

Hi All,

Kindly let me know how to disable accessing service portal (/sp) in mobile browser.

 

Thanks in advance

3 REPLIES 3

Amit Gujarathi
Giga Sage

HI @guestee ,
I trust you are doing great.

To prevent access to the Service Portal (/sp) on mobile browsers in ServiceNow, you can utilize User Agent detection in a Scripted REST API or a UI Script. Here's a basic approach:

  1. Scripted REST API:
    • Create a Scripted REST API that checks the User Agent of the incoming request.
    • If the User Agent matches a mobile browser, redirect the user to a different page or display a message indicating that the Service Portal is not accessible on mobile.

 

var userAgent = request.getHeader('User-Agent');
if (/mobile/i.test(userAgent)) {
    // Redirect or display a message
}

 

UI Script:

  • Create a UI Script that runs on the Service Portal.
  • Check the User Agent of the browser, and if it matches a mobile browser, redirect the user or display a message.

 

if (/mobile/i.test(navigator.userAgent)) {
    // Redirect or display a message
}

 

Hi Amit, Thanks for your time taken to reply my email.

This is custom solution is there any OOB solution available.

guestee
Tera Contributor

Hi Amit, I tried both the solution but it is not working

guestee_0-1696413071161.png