Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Why Auto-Population Doesn't Work for Child Form on Mobile (and How to Fix It)

iftekharmir
Tera Contributor

Overview

Auto-population in ServiceNow Mobile Apps often fails—not because of script issues—but due to incorrect table mapping between the Mobile function and the Mobile Action Item.

Mobile auto-population behaves differently from the desktop UI. For the value to populate correctly, the Mobile function must reference the parent table, while the Mobile Action Item and Mobile Input Form must reference the child table where the field actually exists.

If these table mappings don’t match, the mobile form cannot receive or apply the value, causing the auto-population to silently fail.

This article explains how to correctly configure auto-population using your real use case:
Auto-filling the Account field on the Interaction (interaction) form when creating an Interaction from an Account (customer_account) record in the mobile app.


Why Auto-Population Fails on Child Forms

 

Cause 1: Incorrect Mapping Between Script Include Function and Action Item

This is the most common root cause.

When auto-populating a child table field from a parent table record, the mapping must follow this rule:

Component Must Point To
Mobile FunctionParent table (Account)
Mobile Action ItemChild table (Interaction)
Mobile Form InputChild table (Interaction)

If these point to the wrong tables, the mobile app will not pass the parent record to the script → and the value will never auto-populate.

 

Cause 2: The Function Doesn’t Return the Field in the Correct Mobile Format

Mobile input fields require the Script Include to return an object with:

  • Value → sys_id

  • DisplayValue → label shown in the field

Returning only a sys_id (standard desktop behavior) will fail on mobile because the mobile UI cannot interpret the display value.

 

Cause 3: Script Include not marked as "Mobile Callable"

Mobile requires Script Includes to be explicitly accessible.
If Mobile Callable is not enabled, the Mobile Agent app cannot execute the function—even if it works in the desktop UI.

 

Use Case

 

Populate a Account value on the Interaction form in Mobile


Create a Script Include:

    1. Must return both Value and Display Value.
    2. Must be Mobile Callable

 

var AutopopulateUtils = Class.create();
AutopopulateUtils.prototype = {

    initialize: function() {
    },

    getIncidentInfo: function() {
        var inc = new GlideRecord('incident');

        if (inc.get(current.sys_id)) {
            //gs.log(current.sys_id);
            return {
                "Value": inc.getUniqueValue(),
                "DisplayValue": inc.getDisplayValue() // incident number
            };
        }
    },

    type: 'AutopopulateUtils'
};
 
Configure Mobile Function (Parent Table Reference)
  Must reference Account (parent table)
iftekharmir_0-1764929053529.png

 

Configure Mobile Action Item (Child Table Reference)
Must reference interaction (child table)
iftekharmir_1-1764929212934.png

 

Configure Mobile Input Fields:

1. Create an Account Variable and set the variable type to Scripted.

iftekharmir_5-1764929347562.png

 

2. Create a Variable Attribute and choose the attribute Script, reference the Script Include function.

 
iftekharmir_6-1764929412602.png

 

3. Link the variable in the Mobile Input Field. Under the Autofill variable option, select the Assignment Group variable you created.

 
iftekharmir_7-1764929473333.png

 

Result

Once configured, the Account field will automatically populate with the predefined value when you open the form in the mobile app. This approach ensures consistent and reliable field population across ServiceNow Mobile environments.

 

 

0 REPLIES 0