Why is window null in Desktop (Snow UI) and Mobile/Portal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2019 01:08 PM
Based on docs (https://docs.servicenow.com/bundle/madrid-servicenow-platform/page/build/service-portal/concept/unsu...) I created a Catalog Client Script that run in ALL (mobile and Desktop). In the script I want to know when the script is running on mobile/portal or Desktop, since Desktop code will not work on Portal/mobile.
I am using the following condition:
if(window===null){
alert("portal/mobile");
}else{
alert("Desktop");
}
But window is ALWAYS null, I do not know what to do I will appreciate your help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2019 01:24 PM
Otherway to do it try and catch
try {
//Works in non-portal ui
} catch(e) {
//For Service Portal
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2019 01:25 PM