Autopopulate Fields in Mobile Input Form

Author: Rohan Aditya

Key points covered:

  • Why your Script Include ignores you in Mobile
  • How to use Mobile Callable Script Includes
  • Autopopulating fields in Mobile Input Form

Quick Navigation

Why It Refuses to Work and How to Convince It

Your Script Include isn’t working in the mobile input form? You double-checked the code, cleared cache, maybe even whispered a prayer — but nothing. Classic developer déjà vu.

Usually, it’s one of these two sneaky culprits:

  1. The Mobile Callable checkbox is still unchecked. Without it, the Agent Mobile app completely ignores your Script Include — like that one teammate who reads messages but never replies.
  2. You’re returning only the sys_id like the old desktop days. Mobile wants a JSON object with both Value and DisplayValue. Skip that, and you’ll just get a blank stare from your input field.

Fix both, and your form will finally come to life — no rituals required.

Let’s Consider a Use Case: Populating Assignment Group

Imagine you have a mobile form where users create an Incident or Case, and you want the Assignment Group field to automatically populate with a default value — for example, IT Service Desk.

This can be easily achieved using a Mobile Callable Script Include that runs when the form loads. Instead of manually selecting a group every time, the system fills it automatically, improving both speed and consistency for your users.

The process looks like this:

  1. Create a Script Include that returns both Value and DisplayValue for the group.
  2. Mark it as Mobile Callable so that it can be accessed from the Mobile app.
  3. In your Mobile Input variable, use the Script attribute to call the function.

Once done, each time a user opens the form in the mobile app, the Assignment Group will already be populated.

Implementation Steps

Step 1: Create Script Include

Go to System Definition > Script Includes and create a new one. Mark it as Mobile Callable, and return both Value and DisplayValue for your default group.

Step 2: Create Assignment Group Variable

In your Mobile Input Form, create a new variable for Assignment Group and set its type to Scripted.

Create Assignment Group Variable in Mobile App

Step 3: Configure Variable Attribute (Script)

Open the variable’s attributes, select Script as the name, and call your function in the value field: MobileUtils.populateDefaultAssignmentGroup();

Set Script attribute for Variable in ServiceNow

Step 4: Configure Autofill Variable

Create an Assignment Group input field in your form and select the above scripted variable under the Autofill Variable option.

Assignment Group Input field autofilled in mobile form

That’s it! Now when you open the form on your mobile device, your Assignment Group field will automatically populate with the default value.