---
sourceDocument: Brazil Mobile Configuration and Navigation
sourceDocumentLink: https://www.servicenow.com/docs/r/mobile

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil Mobile Configuration and Navigation

ft:clusterId :

    - mobile

bundleId :

    - mobile

workflow :

    - Development, Data and Analytics


---

# Dynamic variable support in record screens

# Dynamic variable support in record screens {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of Dynamic variable support in record screens

ServiceNow's dynamic variable support in record screens enables you to use script fields to display dynamic, computed field values on forms without altering the underlying database values.
This capability is particularly useful for showing personalized or translated content dynamically within the mobile app, enhancing the user experience by providing context-specific data such as personalized HR case descriptions in the employee's preferred language.
Show full answer Show less  
Note that the script field configuration for record screens is done within the ServiceNow AI Platform rather than the Mobile App Builder, distinguishing it from other screen field configurations.

## Key Features

* **Dynamic display of field values:** Use scripts to calculate and show dynamic content on record screens while preserving original database values.
* **Script field configuration:** Configure the script field by selecting the Type as *Script* and linking it to a field containing the dynamic variable.
* **JSON-based script output:** Scripts must return a JSON object with two required properties: **Type** (content format) and **Value** (content to display).
* **Supported Type values:** Auto, Text, Percentage, Date, and HTML, which must align with the selected field type in configuration.
* **Date formatting:** Date values must follow specific formats (e.g., yyyy-MM-dd for dates, yyyy-MM-dd HH:mm:ss for date-time).
* **Use cases supported:** Personalized descriptions, calculated percentages, and dynamically generated date values.

## Configuration and Usage

When configuring dynamic variables in the details screen:

* Set the **Type** field to *Script*.
* Select the appropriate **Form** field containing the dynamic variable.
* Write a script using the prescribed JSON format to return the dynamic content.

The script runs on the mobile app when the field is displayed, allowing real-time dynamic data presentation without modifying stored data.

## Examples

* **Personalized case descriptions:** A script extracts variables from a text field and replaces placeholders with actual field values (e.g., assigned user's first name), returning a personalized message with Type set to 'Text'.
* **Elapsed time percentage:** Calculates and displays a percentage value representing time elapsed between start and end dates, returning a numeric value without the % symbol (which is handled by field formatting).
* **Dynamic date calculation:** Computes date or date-time values dynamically and returns them in the correct format for display on the mobile app.  
Use the script screen field in record screens to display dynamic field values. The script runs to determine the field value before it displays in your form. The value returned by the script doesn't replace the database value.
For example, you can display translated content for dynamic variables within an email.
Note:  
The script field for record screens is configured within the ServiceNow AI Platform and not in the Mobile App Builder, as is the case for the other screen fields within the record screen. For configuration steps, [Configure the script field for records screens](https://www.servicenow.com/docs/rPbM9bjrrr_1ZG_k1VINMA "Configure script screen fields to display calculated or personalized content in your mobile forms, without modifying the underlying database values.").

## Use case {#record-screen-script-type__section_dfz_4ns_k3c}

Employees can view their HR cases and tasks in their preferred language on mobile devices, even when descriptions include personalized information from other fields. Using the script screen field in record screens, you can display
these translated dynamic values in the mobile app. This provides the option for employees to see accurate translations of their HR cases, even when the descriptions contain personalized information.

## Items to note when using dynamic variable support {#record-screen-script-type__section_b1b_14s_k3c}

The following considerations must be met when configuring dynamic variables in the details screen.

* In the Type field, select Script.
* In the Form field field, select a field that contains the dynamic variable you want to use.

{#record-screen-script-type__ul_a2p_c4s_k3c}For full configuration instructions, see [Configure the script field for records screens](https://www.servicenow.com/docs/rPbM9bjrrr_1ZG_k1VINMA "Configure script screen fields to display calculated or personalized content in your mobile forms, without modifying the underlying database values.").

## Working with the Execution Script field {#record-screen-script-type__section_z2h_r4s_k3c}

Use the following script format to return values for display on the mobile app. The script must return a JSON object with two required properties. `Type` defines the content format (in the example it's
`HTML`), and `Value` contains the actual content to display (in the example it's `Hello`).  

    var json = {
    'Type': 'HTML',
    'Value': "<p>Hello! </p>"
    }

Consider the following when working with a JSON script:

* The script must contain the properties `Type` and `Value`
* The Type property can use the following options: Auto, Text, Percentage, Date, and HTML.
* The `Type` in the JSON must be the same as the type selected from the field.
* Date values must use this format: yyyy-MM-dd HH:mm:ss
{#record-screen-script-type__ul_llf_bps_k3c}

## Examples {#record-screen-script-type__section_zwn_qss_k3c}

Example 1: Displaying personalized case descriptions
:   Consider an HR case description field containing a variable that references the assigned user's first
    name:

        'Hi {current.assigned_to.first_name}, Unable to access the personal details section in payroll portal.'

    The script after this extracts the variable, retrieves the actual field value, and returns a personalized description:

        'Hi Beth, Unable to access the personal details section in payroll portal.'

    The script returns the updated text with Type set to 'Text'. For HTML content, set the Type to 'HTML'.  

        (function generateScreenField(current) {
            //Type appropriate comment here, and begin script below 
            var description = current.description;
           var regex = /\$\{(.*?)\}/; 
           var match = description.match(regex); 
           var fieldName = match[1]; 
           var element = current.getElement(fieldName); 
           var fieldValue = element.getValue(); 
           var updatedDescription = description.replace(regex, fieldValue); 
           var json = { 
               'Type': 'Text', 
               'Value': updatedDescription 
           }; 
           return json; 
        })(current);

Example 2: Calculating elapsed time as a percentage
:   The script calculates the percentage of time elapsed between start and end dates and displays it in a percentage field on the details screen.  
    Note:  
    The percentage value returns with a numeric value and without the % symbol. The symbol is handled by the field formatting.

        (function generateScreenField(current) {
            //Type appropriate comment here, and begin script below 
            //Logic to calculate percentage of time elapsed between start and end dates
            //Return percentage without % symbol
           var json = { 
               'Type': 'Percentage', 
               'Value': timeElapsedPercent 
           }; 
           return json; 
        })(current);

Example 3: Calculating date values dynamically
:   This script calculates a date and displays it in a date field. The script runs when the field appears on the mobile app, calculates the date based on your logic, and returns it in the correct format.  
    Date format requirements:

    * Date only: yyyy-MM-dd (example: 2025-01-29)
    * Date with time: yyyy-MM-dd HH:mm:ss (example: 2025-01-29 14:30:00)
    {#record-screen-script-type__ul_w3m_f5s_k3c}

        (function generateScreenField(current) {
            //Type appropriate comment here, and begin script below 
            //Logic to calculate value of the Date field
            //Return Date in the following format: yyyy-MM-dd (without Time)
            var json = { 
               'Type': 'Date', 
               'Value': calculatedDate
           };
        (or)
           //Return DateTime in the following format: yyyy-MM-dd HH:mm:ss (with time)
           var json = { 
               'Type': 'DateTime', 
               'Value': calculatedDate
           };

           return json; 
        })(current);


