Configure Communication between Widget Control and Form
- Last UpdatedNov 15, 2023
- 2 minute read
To configure communication between Widget control and a Form, you need to set the Widget Type as Form in the Widget control. Also, the Form Details property needs to be specified, which will be addressed as the Target Form in this topic. For information on specifying the Form Details property, see Widget.
Read more in below topics on how to establish the communication between the Widget control and the Target Form:
Initialize Communication
To initialize communication, you need to write the scripts in the Target Form. The below script can be used in the On Form Load script to initialize the communication context:
SFU.initializeWidgetFormCommunication(control);
To establish communicate between the Widget control and the Target Form, you need to define Form Parameters for the Target Form. So, when you configure the Widget control with Widget Type as Form and set the Form Details property to the Target Form, it would list the Form Parameters defined in the Target Form as the Widget properties. These Widget properties will be the communication points between the Widget control and the Target Form.
Note: Form Parameters are considered as Widget Properties for the Widget control irrespective of the data type. The Widget Properties are always represented as String data type.
Capture Values
To capture the values in the Target Form when the Widget control property is updated, you need to define the script as below (can be done for all the Widget properties, which needs to be captured):
ifc_msgHandler["FormParameterName"]= function(value){
// write scripts to update the UI with the value coming
// from the widget control to the form.
};
where, FormParameterName is the Form Parameter defined in the Target Form, which would be the Widget Property name in the Widget control.
So, the On Form Load script will look like as shown below, which includes the initialization part as well:
SFU.initializeWidgetFormCommunication(control);
ifc_msgHandler["FormParameterName"]= function(value){
// write scripts to update the UI with the value coming
// from the widget control to the form.
};
Send Values
To send values from the Target Form to the widget control, you need to define the script as below:
ifc_send("FormParameterName", "Value to be sent");
where, FormParameterName is the Form Parameter defined in the Target Form.
The above script can be written as required in the Target Form, like from an On Click script of a button control or an On Data Change script of a Textinput control.
Read URL Parameter Values
The Widget control has a property Add Values as Url and is available only when the Widget Type is set as Form. When Add Values as Url is set to Yes, then the Widget properties, which are the Form Parameters based properties, are passed as URL parameters to the iFrame control used internally to render the Form for the Widget control.
To read the URL Parameter values, use the below script in the Target Form:
var urlParameterValue = ifc_getFormParam("FormParameterName");
where, FormParameterName is the Form Parameter defined in the Target Form.