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.

Steps to Implement

  1. Create a Script Include.
  2. Mark it as Mobile Callable.
  3. In your Mobile Input variable, use the Script attribute to call your function.
  4. Open the Case form in the Mobile app and watch your field auto-populate like magic.

Script Include Example

Here’s an example that automatically sets the Assignment Group when the form opens.


var MobileUtils = Class.create();
MobileUtils.prototype = {
    initialize: function() {},

    populateDefaultAssignmentGroup: function() {

      var assignmentGroup = gs.getProperty('service.desk.group');

        return {
            "Value": assignmentGroup.toString(),
            "DisplayValue": "IT Service Desk"
        };
    },

    type: 'MobileUtils'
};
        

Create Assignment Group Variable and set variable type to Scripted

Create Variable attribute and select name as Script and call script include in Value.

Create Assignment Group Input field, in that under Autofill variable select the above Assignment group variable

And that’s it! Now when you open your form, your Assignment Group shows up by default.