How To Dynamically Change A Form Component Value Using The Advanced Logic Feature

How to dynamically change a Form component’s value using the “Advanced Logic” feature ?

Make use of the “Advanced Logic” feature to dynamically change the schema of a dropdown or a particular text field component’s value. This will allow to develop a dynamic relationship between two different components of the form.

Following Triggers are available in the “Advanced Logic”:

  • Simple
  • JavaScript
  • JSON logic
  • Event

Any of the following actions can be set after any one of the above triggers has been provided:

  • Property – Multiple properties such as hidden, required, disabled, Label, title, etc., can be set for the component.
  • Value
  • Merge component schema

Below is an example scenario:

Problem statement: The row values of the first column of a data grid should be available as the dropdown values. The Data grid values will be created by the user during runtime and are not static.

Solution:

  1. Create a JavaScript trigger for the dropdown component that always returns “True” as shown below.

  1. Create the “Action” logic using the below JS code to set the dropdown schema. The below code returns the schema.

function ddArray(){

var arr = [];

var i;

for (i = 0; i < data.dataGrid.length; i++) {

arr.push(data.dataGrid[i].num);

}

return arr

}

schema = {data: {values: ddArray()}}

Note: Form Activity package version >= 1.1.6 is supported. For using custom JS logic in the "Create Form Task" activity, use either Cloud Actions or On-Prem Action center. (Orchestrator Actions does not support this yet.)

1 Like