Including the API in your widget
Setting the return value of the widget
Widgets can store a value just like other types of fields. If you want your widget to return a value to the form, you can use the SetReturnValue() function.
The value returned is stored as a string (text) and can be used to determine skip logic and can have validation rules applied.
Setting other field values in your form
Widgets can also update the values of other fields in your form. If you want your widget to set a particular field's value in the form, you can use the SetFieldValue() function.
// Call this function when you wish to set the value of a field in your form. MobenziWidgetAPI.SetFieldValue("yourFieldName","yourValue"); // You can also update a specific instance of a field inside a repeat group by including the optional zero-based repeat index parameter. MobenziWidgetAPI.SetFieldValue("yourFieldName","yourValue",yourRepeatIndex);
Accessing data passed to the widget
Often, values are passed to a widget from the main form. These can be retrieved from the widget using the GetParameter() function.
// This example assumes you pass two parameters to the widget: "mode" and "limit". var mode = MobenziWidgetAPI.GetParameter('mode'); var limit = MobenziWidgetAPI.GetParameter('limit');
Programmatically setting the widget field height
In some cases, you might want to set the height of the custom widget dynamically to avoid displaying scrollbars and have the widget's height match the content that it contains. This can be achieved by calling the SetHeight() function.