MaestroThe UI design product. |
Form Builder Platform Developer | 19.05
This feature was introduced in 19.05.
Many applications require some type of reference data that infrequently changes, such as lists of countries, vehicle manufacturers, models, years, titles, product types, and so on.
Journey Maestro allows Form Designers to access reference data using the following techniques:
The Form Designer supplies JavaScript source, which is embedded directly into the form as a JavaScript Library component. Reference data under this scenario stays with the form and has no external dependencies, with the benefit that versioning of the data is managed by Maestro as part of the form content.
The reference data here is embedded in the form inside a JavaScript library. In the sample data below, we have used the property names label
and value
in our JSON object. These property names are the default values for displaying in Data Driven Dropdown components. By using these names, we can accept the default values for the dropdown's Label Field
and Value Field
properties. We can use any names we want in our JSON though, and simply change the dropdown properties to suit. To do this, follow these steps:
motorCyclesReferenceData
.Reference data is stored and managed by Journey Manager and injected into the form's XML data at the time of the rendering of the form. There is a non-trivial setup process required in Manager, but one benefit is that reference data remains external to the form. For more information, see Prefill a Cascading Dropdown in Composer and Form Prefill for Anonymous Users. Be aware that prefilled data will be returned along with other data fields in the submission XML. For this reason, using prefill for reference data is not the ideal choice. For example, if your reference data is a list of country codes, you don't really what to have this data come back in the submission XML.
The reference data here is held in Manager as a Form Property. Before you can assign a value to a 'Property', you need to create a Property Type for it. To do this, follow these steps:
data.$tempManufacturers
.data.$tempManufacturers = JSON.parse(data.manufacturerspropertydata);
delete data.manufacturerspropertydata;
delete data.prefill.manufacturerspropertydata;
$tempManufacturers
- form fields with names beginning with '$', are not sent back in the submission XML data. It removes the manufacturerspropertydata field from the form data object, so it will not be sent back in the submission XML. It also removes the manufacturerspropertydata field from the form prefill data object, otherwise it will be merged back into the form data object before submissionMotorcycles.json
file.
If you try to create a new property of the same Property Type in your form, you cannot do that. A Property Type can only be given a value by one Property in the same form.
Reference data is stored and managed by running a custom Fluent Groovy Service in Manager and made available at run-time when the form decides to fetch it. An advantage of this method is the potential ability to dynamically filter the data. Reference data is still external to the form using this method, but it does require the creation of a service in Manager. A form builder will need to write code to persist the dataaccess the service and deal with the response.
The table below lists compares the features of each techniques.
Feature | JavaScript Library | Property Pre-fill | Dynamic Data Service |
---|---|---|---|
Works in Preview mode | Yes | No | No |
Version control | Managed by Form versioning | None | Determined by service |
Use When | form-specific data infrequent data changes no sharing required static data required work entirely in Maestro | sharing required static data required need to override at org/form/user | filtering requiredsharing required |
Manager content validation | N/A | Yes | Determined by code |
Supports lazy-loading | No | No | Yes |
Share-ability | None | Shareable | Shareable |
Security | None | None | Determined by code |
Re-publish required after change | Yes | No | No |
No-code implementation | No | Only for simple data type | No |
Impact on save/retrieved forms | No | May break | None |
Impact on review task forms | None | May break | None |
Good Points | easy to implementno TM action requiredversioned with formno server calls needed | content managed by TMhierarchical org/form/user overridesno server calls needed | most flexiblelazy loadabilityfilterablesecurable |
Filterable data source | No | No | Yes, if coded |
Data variability | Static | Static | Dynamic, if coded |
Data type | Object | String, can be converted to Object in code | Object |
Data source | Embedded in JavaScript code | TM Properties | Determined by service |
Data instance location | Global context | Form XML | Determined by code |
Data associated with | Form | Organization / Form / User | Determined by service |
Complexity of TM setup | Not required | Medium | Complex |
Bad points | re-publish on change scope directly to form cannot be shared static data only | complex TM setup may break review / retrieved forms code required for object conversion initially, but contaminates form XML static data only | higher coding requirement overkill for simple cases |
Each of the following guides details how to gain access to reference data using the techniques discussed above. In each case, we populate an initial Data Field with some sort of data (for this example we will use data from motorcycle manufacturers). At the end of the guides, we will demonstrate methods of using the manufacturer's data to build cascading data dropdowns. Building the cascading dropdowns with each method is exactly the same process, the only difference is how you initially obtain the reference data.
Here we will create a new Manager service which will return our JSON as text. Then we will call the new service from a form to populate a dropdown as before. We will call our new service from the form's Load event.
DynamicData.call("Motorcycle Manufacturers", {}).then(function(response) {data.manufacturersdds = response;});
To complete your reference data implementation, you need to add cascading dropdowns. Here we will add additional dropdowns for Model and Year to the form. When the value selected in the manufacturer dropdown changes, the model will be re-populated with the models available from the chosen manufacturer. Similarly, when the model dropdown selection changes, the years dropdown will be re-populated.
Because we have continued to use the 'label' and 'value' properties throughout all levels of our JSON data, we don't need to change the 'Label Field' and 'Value Field' properties on any of the dropdowns.
The instructions here relate to the initial Data Field named 'manufacturers' and Dynamic Data Dropdown called 'manufacturer'. We created these components in the JavaScript library method. If you followed the JavaScript Library instructions and saved your form, re-use that form here so that your data fields and dropdown names match these instructions.
var selected = data.manufacturer;
data.manufacturers.some(function(element) {
if (element.value === selected) {
data.models = element.models;
data.years = undefined;
return true;
}
});
return undefined;
data.years = data.models.filter(function(element) {
return element.value === data.model
})[0].years;
Now when you render the form, you will see the cascading behavior between the Manufacturer, Model, and Year dropdowns.
Next, learn about pre-submit validation.