2
1
0

I have a data driven dropdown in my form and I want to prefill data into it on form load.

How do I do this?

    CommentAdd your comment...

    1 answer

    1.  
      3
      2
      1

      To Prefill data from a prefill service. Follow the example below.

      The prefill service:

      In this case we want a list of the US State names in the dropdown. So we will use a pipe delimited string to prefill into a StatesList key in the form data object.

       

      Accessing prefill data

      To access this string in the Maestro form use the following code:

      Form.prefill.StatesList

      The Form.prefill object contains all the prefilled data, and StatesList is the key used to prefill in this case.

      Adding the Form Load Rule

      Add a Form Load Rule to store this data in the Form.data object so we can use it in our data driven dropdown:

      Open Form Options:

      Select Form Rules:

      Create a Form Load rule with the following code:

      data.$statesList = Calc.pipedSelection(Form.prefill.StatesList);

      There are a couple of things happening here:

      The Calc.pipedSelection method will take in the pipe delimited string and convert it into an array of objects. This is the format supported by the data driven dropdown.

      We will store this array in a special dollar sign key called data.$statesList, this is because we do not want this data in the XML and won't be changing it dynamically during the form run time. (If we want to add more in the form we can do this by pushing more objects into this array. Or use a data field to hold the data).

      Save the rule.

      Adding and setting up the data driven dropdown

      Drop a data driven dropdown into the form

      Set the Data Source to be data.$statesList

      And you are ready to go.