10.4 Value Change Handler
Description: This attribute is used to handle the events, when the value of an element is changed.
Components to accept the input: Switch, select box, and code editor
When user enables the switch, it will display an input box and a button as shown in the below image.
- REST API Chain: To understand REST chaining, please refer REST API Chaining section. This select box lists all the REST API chaining that user has created in step four i.e. REST API Configuration. From this select box, user can select REST API chain that he wants to fire when the value of an element is changed.
- Hook function: There is a button named as “Open Editor”. When user clicks on this button, it will open a code editor as shown in the below image. In this editor, user can write the code to be executed when the value of an element is changed.
To understand more about editor, refer Open Editor of hook function section.
- User has two select box options
- Buyer Name: This select box lists all available buyer names.
- Name of Program: When user selects a buyer name, this select box will lists available programs specific to the selected buyer.
In above example, user will need to fire a REST API to fetch the available programs of the selected buyer. It means the user needs to perform an operation when the value of buyer field changes. In such scenarios, this attribute is used.
Usage: Enable the “value change handler” switch.
Select the REST API that user needs to fire when the value of buyer field changes as shown in the below image.
Now if user clicks on the “Open Editor” button, it will open the code editor.
A default code is already present in the window generated by the tool. When user selects a REST API, the tool generates the required code to execute that REST API. However, in some cases, there is a need to do some additional operation on the data fetched from the server. Therefore, for this purpose, there is a support for code editor. In such scenarios, use the response variable(highlighted in red circle in the above image) for further processing.
- User has a form and wants to give an option to use this form as a template. If the user says yes, then an input text field is displayed to accept the template name as shown in the image.
Usage: In this example, user will need a variable to handle this case, say “isTemplate”. Initially this variable will have a value set as false (Boolean). it will hide “Template Name” input field. But when the user will select “Yes” option, its value will change to true (Boolean) and it will display the input field “Template Name”.
Enable the “value change handler” switch.
As user does not need to fire any REST API, no REST API is to be selected.
Click on the “Open Editor” button, and write code inside the editor as shown in the below image.
newValue represents the new value of the field. If user selects “Yes”, newValue will be “Yes” and variable will be true. If user selects “No”, newValue will be “No” and variable will be false. Whenever the value of radio button changes, it will execute this block of code.
Note:
As there is no REST API selected, there will be no auto-generated code.Parent topic: Available Attributes







