Skip to content

Field Logic Schema

Randall Knutson edited this page Feb 21, 2018 · 7 revisions

An object that contains a trigger object and an array of action objects.

logic: [
  {
    trigger: {}
    actions: [{}, {}]
  }
]

Triggers

Trigger object - The trigger object contains a type and definition property. The definition property is different depending on the trigger type. When evaluated to true it will then apply the actions.

Options are:

Simple Trigger:

{
  type: 'simple',
  simple: {
    when: 'triggerFieldKey',
    eq: 'Value to equal',
    show: true // To trigger or not when the value is equal
  }
}

Javascript Trigger

{
  type: 'javascript',
  javascript: 'result = customJavascriptReturningFalsyValue;'
}

JSON Logic Trigger

{
  type: 'json',
  json: {} // JSON Logic object that returns true or false.
}

Actions

Action object - a definition of an action to be applied to a component when the trigger evaluated to true. There are various options for the action type.

Property action

The property action will change a property on the component and then redraw the component to ensure the property change is applied.

{
  type: 'property',
  property: {
    type: 'boolean|string', // If the property is a boolean, set 'boolean'. Otherwise set 'string'.
    value: 'validate.required', // The path to the property on the component definition.
  },
  state: true|false // If type is boolean, set to true or false.
  text: 'The text is {{ myfield }}' // If type is string, the string to assign. Can use interpolation with available variables of row, data, component and result (returned from trigger).
}

Value action

The value action will set the value of the component when the trigger evaluated to true.

{
  type: 'value',
  value: 'javascript that returns the new value' // Will be evaluated with available variables of row, data, component and result (returned from trigger).
}

Validation action

This action is in development. It will trigger custom validation on the field.

Clone this wiki locally