ServiceNow mobile - client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2015 11:19 PM
Is it possible to run Javascript with a UI macro in the ServiceNow mobile view?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2015 01:35 AM
Indeed it's possible and you can use gs.isMobile() to know if you're on a mobile device.
As a reference:
Smartphone detection in UI Page or UI Macro or in Jelly Scripting?
Configuring the Legacy Mobile UI - ServiceNow Wiki
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2015 02:16 AM
Thanks Berny,
I should have mentioned it earlier, but my requirement is to run client side javascript on mobile.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2015 07:25 AM
Hi Saurav, unfortunately that will not work. To be sure i did a very quick test on my own adding the following code in a UI macro which I ran using the mobile view.
function getValue(){ | |
return 'SOMETHING'; | |
} | |
</script> | |
<input type="text" onClick="this.value = getValue();" /> |
And when clicked the input textbox 'SOMETHING' is not assigned as the textbox value.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2023 08:06 AM
ServiceNow's mobile view does not support running JavaScript directly within UI macros. This is primarily due to security restrictions and best practices for mobile application development. ServiceNow's mobile platform is designed to provide a consistent and secure user experience across various devices and operating systems.
Instead of using JavaScript within UI macros, ServiceNow provides specific mobile development capabilities, such as creating mobile-friendly UI components and leveraging ServiceNow's mobile app development framework.
For customizing the mobile view in ServiceNow, you can use ServiceNow's Mobile Studio, which provides a set of tools and features for building and customizing mobile apps within the ServiceNow platform. Mobile Studio allows you to create custom mobile UI components, define mobile-specific behaviors, and design mobile-friendly experiences without the need to directly run JavaScript within UI macros.