Auto-populating Wizard Fields using a Datasource Callback
When you must build the ability to auto-populate fields in wizards based on previously entered responses for your integration, you should use the Datasource Callback method. This method also requires passing data to the wizard as in the previous section, but in this case it is retrieving data from one completed wizard and using that data to populate newly-invoked wizards that use the same design.
Wizard Runtime JSON Structure
To properly understand the format of the data returned by the callback to auto-populate a wizard, let's take a look at a sample JSON structure created from a wizard step with two responses:
Sample JSON: Auto-Populate
{
"UserResponses": [{
"Question": "sample question - 1",
"ObjectName": null,
"Notes": [],
"metaPropertyFields": null,
"inputRepeatSequence": 0,
"inputControlId": "a0236000002LNlDAAW",
"FieldName": null,
"FieldClass": null,
"Comments": "",
"Attachments": [],
"Answer": "sample answer - 1"
}, {
"Question": "sample question - 2",
"ObjectName": null,
"Notes": [],
"metaPropertyFields": null,
"inputRepeatSequence": 0,
"inputControlId": "a0236000002LNlEAAW",
"FieldName": null,
"FieldClass": null,
"Comments": "",
"Attachments": [],
"Answer": "sample answer - 2"
}],
"Parameters": null
}
When using the callback method to auto-populate fields in a runtime wizard, the method should return a string using a similar JSON structure as shown in the example above. The values in the JSON string auto-populate the fields when the Wizard is invoked.
The parameters described in the following table are relevant for Callback implementations to auto-populate questions/responses in the Wizard:
Parameter |
Value |
Description |
---|---|---|
Question |
Object/Wizard Input field name |
Provide the name of the field in the Input Control as defined (for example, AccountName or OppName) |
inputControlId |
Id string of Input Control |
Provide the Id string of the input control to be auto-populated (for example, a1561000001dXHf) |
Answer |
Field or Response value |
Provide the value to auto-populated as in the Wizard field/response (for example, Tier One Systems) |
inputRepeatSequence |
Numeric sequence for repeatable Wizard Input Controls |
If the Wizard step uses a "Repeatable" layout for an input, Provide a numeric value to represent each occurrence (for example, first occurrence is "inputRepeatSequence:" 0, next occurrence is "InputRepeatSequence:"1, etc.) |
Implementing a Datasource Callback
The data captured from the previously completed wizard can be from Wizard Input Fields or Object fields. For your integration, you must create a DataSource Callback class that passes this retrieved data to the new wizard runtime instance. The process works as follows:
- A custom Data Source callback class is created to implement the DataSource Callback interface WizardCustomClass.IDataSourceCallback.
- The DataSource Callback class calls a custom getData() method that takes the Wizard Design ID as the primary parameter and a map of parameters passed to the Wizard design.
- The getData() method is used to define values for specific runtime input controls in the Wizard design (questions, answers and values) and creates and returns a JSON string using the same structure interpreted by the Wizard.
- The Wizard Design using the DataSource Callback must have the class name defined in the Wizard Settings section of the Wizard Design.
- When a new wizard is invoked, fields specified by the Callback method are auto-populated.