The JavaScript function written for a Custom Service can return either a simple single value or a single JSON object/array. The Response page of the New Custom Integration Point wizard allows you to map this response to one or more variables that can be accessed by users who are building Flows using the Web Designer.

The root element of the data returned is always called response. (This is the term displayed in the Parameter Name column.) Mapping the response involves selecting the appropriate variable type and specifying a the variable name to be displayed in the Interaction Designer.

A custom IP response can be mapped to:

  • Simple variables
  • Custom Types
  • Collections
  • Dynamic Variables

Mapping to Simple Variables

This technique can be used for any type of response (single value or object).

To map a simple value:

  1. In the Parameter Name column, do not change the default value. (The name should be response.)
  2. From the Variable Type dropdown, select the appropriate parameter type. If you select a collection, specify the type from the Type dropdown list.
  3. In the Variable Name column, enter a meaningful name for the variable. The name assigned in this column is the one displayed to users in the Interaction Designer.

To map an object to simple variables:

  1. In the Parameter Name column, specify a field of the object using the following notation: response.fieldname. This will parse the response into a single variable.

    Note: The text following the period needs to be an exact match to the data that is returned in the JSON response.

    In the following example, the returned object contains two fields: city and temp.

  2. From the Variable Type dropdown, select the appropriate parameter type. 
  3. In the Variable Name column, enter a meaningful name for the variable. The name assigned in this column is the one displayed to users in the Interaction Designer.
  4. Repeat Steps 1-3 until all fields of the object are mapped to variables.

Mapping to a Custom Type

A Custom Type is a variable that contains a set of fields related to a specific object. (For example, a Custom Type representing a Customer object would contain fields such as First Name, Last Name, Address, Age, and so on.)

Existing Custom Types are listed at the end of the Variable Type dropdown list. To map a returned JSON object or array into a Custom Type, select the type from the list, or create a new Custom Type that is relevant to the response.

  1. In the Parameter Name column, do not change the default value. (The name should be response.)
  2. From the Variable Type dropdown, select the appropriate Custom Type. Alternatively, create a new Custom Type. For details, refer to Working with Custom Types in REST IP Responses.
  3. In the Variable Name column, enter a meaningful name for the variable. The name assigned in this column is the one displayed to users in the Interaction Designer.

Mapping to a Collection

A Collection contains a list of items. Simple collections contain values of the same data type (e.g., a list of numbers). Object collections contain a list of items (objects) that are each made up of a set of fields.

  1. In the Response panel, from the Variable Type dropdown list, select Collection.
  2. Click on the field to the right of the words of type, and from the options menu, select the variable type created to hold the set of response values.

  3. In the Variable Name field, enter a name for the variable that will store the Collection.

Mapping to a Dynamic Variable

A dynamic variable consists of a JSON object, enabling its content to be changed anytime to suit the current data needs of a Flow.

  1. From the Response panel, enter values for one or more Parameter Name fields. If needed, you can enter a specific JSON path to parse, for example: ListCities.geolocation.
  2. Select Dynamic from the Variable Type dropdown menu:

  3. In the Variable Name field, enter a name for the dynamic variable that will contain the entire response, or specify a JSON path if needed.
  4. Complete the wizard to finish creating the new Integration Point.

You can parse the JSON object IP response to extract the specific data that you need for the Flow. For details on using dynamic variables in Interact, refer to Using Dynamic Variables.

Revision:

Comments