Disable accessing serviceportal in mobile browser
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 09:20 PM
Hi All,
Kindly let me know how to disable accessing service portal (/sp) in mobile browser.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 10:33 PM
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:
- 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
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 02:21 AM
Hi Amit, Thanks for your time taken to reply my email.
This is custom solution is there any OOB solution available.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 02:51 AM
Hi Amit, I tried both the solution but it is not working