# Create Options List From Array of Objects (RWC)

The Create Options List from Array of Objects (RWC) is a helping Step template for Request Response (RWC). Request Response (RWC) has many components that provide users a choice among anticipated replies. Some of them have { label: ``, value: ``} data structure for the content of their options. In particular, they are:

  • Checkboxes
  • Dropdown option
  • Reodarable list
  • Option from list
  • Quick reply button
  • Radio button option If the data you have does not fit the structure required by the component, you can't use it in Request Response (RWC). For example, it can be data passed from another RWC Step, a database, or an API call. The Create Options List from Array of Objects (RWC) Step template serves to reformat the data structure. It takes one array in JSON format and transforms its data into an array of objects with the { label: ``, value: ``} structure. As a result, you get the data reshaped for the Request Response (RWC) Step template and can build a message with user reply options.

Use this Step to create a key-value list from a cusrom array, to use it in RWC components. The step might be added at any place of a Flow tree, so once the Step is executed, the list with options in specific structure will be stored to the Step Merged fields (opens new window).

# Map data from array of objects

Allows to select the source of a custom array to extract data by property paths to a label/value schema of the options list. Source array can be specified as a merge field variable or set as JavaScript expression. Label and value properties are strings and will map the data to options list object.

# step configuration preview

Step configuration preview

# users merge field:

[
  {
    firstName: 'Jonathan',
    lastName: 'Anderson',
    email: 'jonathan.anderson@onereach.com'
  },
  {
    name: 'Robb',
    lastName: 'Wilson'
    email: 'steve.jobs@onereach.com'
  },
  {
    name: 'Petro',
    lastName: 'Tarasenko'
    email: 'petro.tarasenko@onereach.com'
  },
  {
    name: 'Stas',
    lastName: 'Glegov'
    email: 'stas.glebov@onereach.com'
  }
]

# Result

[
  {
    label: 'Jonathan',
    value: 'jonathan.anderson@onereach.com'
  },
  {
    label: 'Robb',
    value: 'steve.jobs@onereach.com'
  },
  {
    label: 'Petro',
    value: 'petro.tarasenko@onereach.com'
  },
  {
    label: 'Stas',
    value: 'stas.glebov@onereach.com'
  }
]

# Customize created options list

Allows to change the options sorting by label or by value and to filter the list by leaving unique labels or values.

# Append options list

Allows manually append options list by adding label and value. Appended options can be sorted separetely or within the extracted list. Filtering are applied for all options: extracted and added manually.

# Merge field settings

The output data of the step will be stored under the name provided in merge field name. Output data structure:

{
   options:[
      {
         label: 'foo',
         value: 'bar'
      }
   ]
}

# Error handling

Process error is on by default and adds an error leg to the step. The flow will exit through this leg if any error was encountered during the execution of the step (e.g. if Source array is empty or has value null, or undefined, or NaN).

# Reporting events

Step event is reported once the flow exits the step. It collects the data which can be used further in reports. You can specify tags to organize the collected data.

Last Updated: 11/20/2023, 4:43:13 PM