MobileScriptIncludeCaller - Client

  • リリースバージョン: Australia
  • 更新日 2026年03月12日
  • 所要時間:6分
  • Provides methods to call script includes from Mobile UI Rule Actions.

    This API can be used with the m_form - Client API to auto-fill inputs on input form screens. For more information about input form screens, see Input form screen.

    Use this API in the Client script field of a Mobile UI Rule Action. For instructions on configuring a Mobile UI Rule Action with the correct settings for this API, see Configure auto-fill inputs on input form screens.

    The script include must have the Mobile callable field selected to be called by this API.

    MobileScriptIncludeCaller - MobileScriptIncludeCaller(String scriptName, String functionName)

    Creates an instance of the MobileScriptIncludeCaller class with the script include and function to call.

    表 : 1. Parameters
    Name Type Description
    scriptName String Name of the mobile-callable script include to call.

    If the script include supports cross-scope access and it's in a different scope than the client script, the name of the script include must be prefixed with the scope.

    functionName String The public function to call in the script include.

    This example shows how to create an instance of the MobileScriptIncludeCaller class that can be used to call the getBusinessTitle() function in the UserUtilsTest script include.

    var caller = new MobileScriptIncludeCaller("UserUtilsTest", "getBusinessTitle");

    MobileScriptIncludeCaller - addParam(String key, Object value)

    Adds a parameter to pass when calling the script include.

    This method enables you to pass values from the input form to the script include.

    表 : 2. Parameters
    Name Type Description
    key String Key to use for the parameter.
    value Object Value of the parameter.
    表 : 3. Returns
    Type Description
    None

    This example shows how to add the value of the employee_id input from the input form to the MobileScriptIncludeCaller object.

    var employeeId = m_form.getValue("employee_id"); 
    var caller = new MobileScriptIncludeCaller("UserUtilsTest", "getBusinessTitle"); 
    caller.addParam("employeeId", employeeId);

    MobileScriptIncludeCaller - call(Function successCallback, Function errorCallback)

    Calls the script include specified by the constructor.

    The server call executes asynchronously and the script include's response is passed to the callback function. If the response from the server fails, for example if the script include isn’t found, the response argument passed to the callback is empty or null.

    The script include must have the Mobile callable field selected to be called by this method.

    表 : 4. Parameters
    Name Type Description
    successCallback Function Optional. The name of the callback function to process the results returned by the server.

    If a callback function isn’t provided, this method returns a promise, which can be consumed using the Promise API.

    errorCallback Function Optional. The name of the callback function to call if an error occurs.
    表 : 5. Returns
    Type Description
    None

    This client script passes the employee_id input value to the script include, which uses the ID to look up the employee's title. The title is provided to the callback function, which it uses to auto-fill the business_title input on the input form screen.

    // Client script in a Mobile UI Rule Action
    function onChange(inputName, newValue) { 
       var employeeId = m_form.getValue("employee_id"); 
       var caller = new MobileScriptIncludeCaller("UserUtilsTest", "getBusinessTitle"); 
       caller.addParam("employeeId", employeeId); 
       caller.call(function(response) { 
          m_form.setValue("business_title", response); 
       }); 
    }

    Script include.

    // Mobile callable script include
    var UserUtilsTest = Class.create(); 
    UserUtilsTest.prototype = Object.extendsObject(global.AbstractMobileCallableInclude, { 
       getBusinessTitle: function() { 
          var employeeId = this.getParameter("employeeId"); 
          var gr = new GlideRecord("sys_user"); 
          gr.get(employeeId); 
          return gr.getValue("title"); 
       }, 
       type: 'UserUtilsTest' 
    });