Dynamic Data Service to Access Reference Data

   MaestroThe UI design product.  |   Form Builder Platform Developer |  19.05 This feature was introduced in 19.05.

While building onboarding application forms, you can use various reference data to pre-fill and autocomplete form's fields, as well as validate user input against this data. Reference data is static data that is created and stored in Manager and it is pertinent to an organization, which Maestro forms, belonging to that organization, can access.

As we showed in Topics, you can access reference data using property prefill. However, Journey Maestro also allows you to access reference data using the dynamic data service. In this case, reference data is stored and managed by running a custom Fluent Groovy service in Manager so it's made available at run-time when the form needs to fetch it as per a customer onboarding flow.

An advantage of this method is the potential ability to dynamically filter 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 needs to write code to persist the data and deal with different responses.

To illustrate how to use a dynamic data service, let's create a new Manager service which returns a JSON as a text, so you can call the new service from a form, using the form's load event, to populate a dropdown.

To use reference data with the dynamic data service:

  1. Log on to Manager.
  2. Create a new service using the following configuration:
    • Service Type - Dynamic Data.
    • Service Template - Fluent Dynamic Data.
    • Service Name - Motorcycle Manufacturers.
    • Select a required organization.
  3. Edit a Groovy Script using the following snippet. You need to replace all the existing JSON text between the pairs of triple single-quotes (''') with text from the Motorcycles.json file as shown below:
    String data = ''' [
    	{
    		"label": "BMW",
    		"value": "bmw",
    		"models": [
    			{"label": "F802GT", "value": f802gt, "years": [
    			{"label": "2008", "value": 2008},
    			{"label": "2017", "value": 2017},
    			{"label": "2021", "value": 2021}
    		]}
    	},
    	{
    		...
    	}]
    	'''
    return data
  4. Lo on to Maestro.
  5. Create a new form using the following configuration:
    • Drop a Data Field onto the form and name it as ManufacturersDDS.
    • Drop a Data Driven Dropdown onto the form and name it as Manufacturers From DDS.
    • Double-clicking on ManufacturersDDS and change its Data Source to data.manufacturersdds.
  6. Click Form Options and click Form Rules.
  7. Click Create Rule and select Load under Form.
  8. Enter the following JavaScript code:
    DynamicData.call("Motorcycle Manufacturers", {}).then(function(response) {data.manufacturersdds = response;});
  9. Click Save to update the rule.
  10. Click Save to save the form.
  11. Publish the form and render it to see data fetched by the dynamic data service in the dropdown

Next, learn how to use a cascading dropdown.