Skip to main content

getFieldValue

This function retrieves the current value of a specified control in the form. It works with all types of controls and returns the value in an appropriate data type for the control.

Syntax

app.getFieldValue(controlId)

Parameters

ParameterTypeDescription
controlIdStringThe ID of the control whose value you want to retrieve

Return Value

Returns the value of the specified control. The data type depends on the control type:

  • Text controls: String
  • Number controls: Number
  • Date controls: String (in ISO format YYYY-MM-DD)
  • Checkbox controls: Boolean
  • Select controls: String or Array (if multi-select)
  • Grid controls: Array of Objects
  • JSON controls: Object

Examples

Example 1: Basic usage with different control types:

// Get value from a text field
const customerName = app.getFieldValue("customerName");

// Get value from a number field
const quantity = app.getFieldValue("quantity");
const total = quantity * 10.99;

// Get value from a date field
const orderDate = app.getFieldValue("orderDate");

// Get value from a checkbox
const isUrgent = app.getFieldValue("urgentOrder");

Example 2: Working with select controls:

// Get selected option from a dropdown
const selectedCountry = app.getFieldValue("country");

// Check if a specific option is selected
if (selectedCountry === "Germany") {
app.setFieldValue("currency", "EUR");
}

// Get multiple selections from a multi-select list
const selectedProducts = app.getFieldValue("products");
console.log("Selected products count: " + selectedProducts.length);

Example 3: Accessing data from a grid control:

// Get data from a grid control
const orderItems = app.getFieldValue("orderItemsGrid");

// Calculate total amount
let totalAmount = 0;
for (let i = 0; i < orderItems.length; i++) {
totalAmount += orderItems[i].quantity * orderItems[i].unitPrice;
}

app.setFieldValue("totalAmount", totalAmount);

Example 4: Working with complex data:

// Get data from a JSON control
const addressData = app.getFieldValue("addressJson");

// Use properties from the object
const formattedAddress =
addressData.street + "\n" +
addressData.city + ", " +
addressData.state + " " +
addressData.zip;

app.setFieldValue("formattedAddress", formattedAddress);
  • setFieldValue() - For setting control values
  • getControlUnmodifiedValue() - For retrieving the original value of a control before any changes
  • markControlAsUnmodified() - For marking a control as unmodified
  • isAppModified() - For checking if any control in the form has been modified

Notes

  • For non-existent controls, the function returns undefined
  • For controls that have never had a value set, the function returns the default value of the control
  • The function retrieves the current value, which may differ from the control's original value
  • For grid controls, the function returns the complete dataset, not just the selected row
  • The function works with any type of control that has a value property
  • Use this function to retrieve current values for validation, calculations, or conditional logic