Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Mobile App - onload Client Scripts do not return the correct value for the g_form.getValue() API - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Mobile App - onload Client Scripts do not return the correct value for the g_form.getValue() API
KB0657642

Mobile App - onload Client Scripts do not return the correct value for the g_form.getValue() API


1470 Views Last updated : Apr 7, 2024 public Copy Permalink
KB Summary by Now Assist

Issue

Mobile App - onload Client Scripts do not return the correct value for the "g_form.getValue()" API



Overview


In the Helsinki release, the API g_form.getValue() invoked from an on-load Client Script fails to return the expected correct value.

For example, on mobile devices, navigating to Incident > Assigned to me loads the list of incidents assigned to current logged-in user. On the list, when you click the "+" symbol, the system creates a new incident record with the Assigned to field populated as the currently logged-in user. During this time, the onload client script, doesn't return the correct value for the g_form.getValue("assigned_to") API. Instead, it returns the value as "javascript:gs.user_id()". Therefore, if you are on the Helsinki release, you cannot build a customization based on the on-load and g_form.getValue() API in new records on mobile devices.

Solution


This issue is resolved beginning with the Istanbul release as part of other enhancements and improvements in the mobile platform. Therefore, if you upgrade to the latest release available, this issue will be automatically resolved.

If you are on Helsinki, apply the workaround.

Workaround


You need to create a new Display business rule with the attributes listed below. In the affected on-load Client Script, use the global scratchpad variable in order to access form values, as, for example, the Assigned To user name. This enables the building of the required business logic with the expected values retrieved.

================================

Table: Incident 

Active: True 

Advanced: True 

When to run => 

When: Display 

Query: True 

Advanced => 

Script: 

(function executeRule(current, previous /*null when async*/) { 

 

g_scratchpad.assignee_sys_Id = gs.user_id(); 

g_scratchpad.assignee_name = gs.getUserDisplayName(); 

 

})(current, previous); 

================================= 

 

=================================

function onLoad() { 

//Type appropriate comment here, and begin script below 

alert("Assigned to:"+g_scratchpad.assignee_name); 

} 

==================================

The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.