Skip to main content

getControlUnmodifiedValue

This function retrieves the original value of a control as it was when the record was initially loaded or last saved. It's useful for detecting changes in form fields, implementing undo functionality, or validating if data has been modified by the user.

Syntax

app.getControlUnmodifiedValue(controlId)

Parameters

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

Return Value

Returns the original value of the specified control with its original type (could be a String, Number, Boolean, Object, Array, or null).

Examples

Example 1: Check if a control value has been modified:

// Compare current value with original value
const currentValue = app.getFieldValue("customerName");
const originalValue = app.getControlUnmodifiedValue("customerName");

if (currentValue !== originalValue) {
// Value has been modified
console.log("Customer name has been changed from: " + originalValue + " to: " + currentValue);
}

Example 2: Implement a reset button for a specific field:

// Reset a field to its original value
const originalValue = app.getControlUnmodifiedValue("description");
app.setFieldValue("description", originalValue);

Example 3: Check if any critical fields have been modified:

// Check for changes in key contract fields
const criticalFields = ["contractValue", "startDate", "endDate", "termsAccepted"];
const hasChanges = criticalFields.some(fieldId =>
app.getFieldValue(fieldId) !== app.getControlUnmodifiedValue(fieldId)
);

if (hasChanges) {
// Ask for confirmation before saving
if (app.showConfirmMessage("Contract Changes", "Critical contract fields have been modified. Continue?")) {
app.saveCurrentRecord();
}
}
  • getFieldValue() - For retrieving the current value of a control
  • setFieldValue() - For setting a control's value
  • markControlAsUnmodified() - For marking a control as unmodified with its current value
  • markAllControlsAsUnModified() - For marking all controls as unmodified with their current values

Notes

  • The unmodified value is set when:
    • A record is initially loaded
    • After a record is successfully saved
    • When markControlAsUnmodified() or markAllControlsAsUnModified() is called
  • This function is commonly used in:
    • Form validation scenarios
    • Custom "discard changes" functionality
    • Conditional logic that depends on whether data has changed
    • Tracking which specific fields have been modified