---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# m_form - Client

# m_form - Client {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read

Provides methods to get and set input values on input form screens, as well as display messages.  
This API supports the following input types:

* Boolean
* Choice
* Date/time
* Number
* Reference
* String
{#m_formClientAPI__ul_hqy_jnl_ccc}

This API can be used with the [MobileScriptIncludeCaller - Client](https://servicenow-prod.fluidtopics.net/HgAs4P~QR3IAGoitsd5jPA#MobileScriptInclCallerClientAPI "Provides methods to call script includes from Mobile UI Rule Actions.") API to auto-fill inputs on input form screens. For more information about input form screens, see [Input form screen](https://www.servicenow.com/docs/access?context=parameter-input-screen&version=xanadu&pubname=xanadu-mobile&ft:locale=en-US).

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](https://www.servicenow.com/docs/access?context=config-autofil-inputs-nptfrmscrn&version=xanadu&pubname=xanadu-mobile&ft:locale=en-US).

## m_form - addErrorMessage(String message) {#ariaid-title2}

Displays an error message at the top of the input form screen.
{#mform-addErrorMessage_S__table_g3q_js2_mbc__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | The message to display. |
[Table 1. Parameters]

{#mform-addErrorMessage_S__table_g3q_js2_mbc} {#mform-addErrorMessage_S__table_h3q_js2_mbc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 2. Returns]

{#mform-addErrorMessage_S__table_h3q_js2_mbc}  
In this example, an informational or error message is displayed on the form depending on the value entered for the priority.

    // Client script in a Mobile UI Rule Action
    function onChange(inputName, newValue) { 
       var priority = newValue; 
       if (priority > 0 && priority < 3) { 
          getMessage("This incident should be handled ASAP", function(response){ 
             m_form.addInfoMessage(response); 
          }); 
       } else { 
          getMessage("The selected priority is invalid", function(response){ 
             m_form.addErrorMessage(response); 
          }); 
       }	 
    }

## m_form - addInfoMessage(String message) {#ariaid-title3}

Displays an informational message at the top of the input form screen.
{#mform-addInfoMessage_S__table_ofb_3s2_mbc__entry__3}

| Name | Type | Description |
|-|-|-|
| message | String | The message to display. |
[Table 3. Parameters]

{#mform-addInfoMessage_S__table_ofb_3s2_mbc} {#mform-addInfoMessage_S__table_pfb_3s2_mbc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 4. Returns]

{#mform-addInfoMessage_S__table_pfb_3s2_mbc}  
In this example, an informational or error message is displayed on the form depending on the value entered for the priority.

    // Client script in a Mobile UI Rule Action
    function onChange(inputName, newValue) { 
       var priority = newValue; 
       if (priority > 0 && priority < 3) { 
          getMessage("This incident should be handled ASAP", function(response){ 
             m_form.addInfoMessage(response); 
          }); 
       } else { 
          getMessage("The selected priority is invalid", function(response){ 
             m_form.addErrorMessage(response); 
          }); 
       }	 
    }

## m_form - getValue(String inputName) {#ariaid-title4}

Returns the value of a specified input on an input form screen.
{#mform-getValue_S__table_lpp_tr2_mbc__entry__3}

| Name | Type | Description |
|-|-|-|
| inputName | String | Name of the input to return the value of. |
[Table 5. Parameters]

{#mform-getValue_S__table_lpp_tr2_mbc} {#mform-getValue_S__table_mpp_tr2_mbc__entry__2}

| Type | Description |
|-|-|
| String | The value of the specified input. Note: If the input is a choice list with multi-select, the return type is an array of strings containing the selected values. |
[Table 6. Returns]

{#mform-getValue_S__table_mpp_tr2_mbc}  
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' 
    });

## m_form - setAffectedInputs(Array inputNames) {#ariaid-title5}

Adds a shimmering effect to specified inputs indicating that the value is being set by a script.
The shimmering effect ends once the value for the input is set.
{#mform-setAffectedInputs_O__table_d1p_ms2_mbc__entry__3}

| Name | Type | Description |
|-|-|-|
| inputNames | Array | Array of strings containing the names of inputs to apply the shimmer effect to. |
[Table 7. Parameters]

{#mform-setAffectedInputs_O__table_d1p_ms2_mbc} {#mform-setAffectedInputs_O__table_e1p_ms2_mbc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 8. Returns]

{#mform-setAffectedInputs_O__table_e1p_ms2_mbc}  
This client script adds a shimmer effect to the caller input to indicate that it's auto-filled.

    // Client script in a Mobile UI Rule Action
    function onChange(inputName, newValue) { 
       var affectedInputs = []; 
       affectedInputs.push("Caller"); 
       m_form.setAffectedInputs(affectedInputs); 
       m_form.setValue("Caller", ["800b174138d089c868d09de320f9833b", "46d44a23a9fe19810012d100cca80666"]); 
       var result = m_form.getValue("Caller"); 
       console.log(`Ref test: ${result[0]}`); 
    }

## m_form - setValue(String inputName, Object value, String displayValue) {#ariaid-title6}

Sets the value of a specified input on an input form screen.
{#mform-setValue_S_S_S__table_tp1_wr2_mbc__entry__3}

| Name | Type | Description |
|-|-|-|
| inputName | String | Name of the input to set the value of. |
| value | Object | Value to set the input to. The data type of the value varies based on the input being set. |
| displayValue | String | Optional. Use this parameter when setting the value of Reference type inputs. |
[Table 9. Parameters]

{#mform-setValue_S_S_S__table_tp1_wr2_mbc} {#mform-setValue_S_S_S__table_up1_wr2_mbc__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 10. Returns]

{#mform-setValue_S_S_S__table_up1_wr2_mbc}  
This example sets an integer value for the order input.

    m_form.setValue("order", 5);

This example sets a string value for the description input.

    m_form.setValue("description", "This is the description content");

This example uses an object containing the value and display value to set a reference type input.

    m_form.setValue("Caller", [{"value":"800b174138d089c868d09de320f9833b", "displayValue":"Abel Tuter"}]);


