Mapper
Use the Mapper action to create custom output by combining outputs of various actions, manipulating values, and restructuring objects, collections, arrays, or strings. This eliminates the need to write complex Node.js codes to retrieve and combine particular field values or outputs from multiple actions.
Complete the following steps to use the Mapper action in your workflow:
1. Click , drag the Mapper action under Developer Tools to the canvas, place the pointer on the action, and then click or double-click the action. The Mapper window opens.
2. Edit the Label, if needed. By default, the label name is the same as the action name.
3. Click to create a key-value pair.
a. Click , and in the Data Types list, select one of the following options:
Array—Use when the specified key returns an array.
Collection—Use when the specified key returns an array of objects.
Object—Use when the specified key returns an object.
String—Use when the specified key returns a String value. By default, all key-value pairs are of the String data type.
b. Rename the key field, if you want.
c. Provide the value or map the output of any previous action as an input to this field. Ensure that you map the output of the correct data type.
If you have set the data type to Collection or Object, you can click next to the collection or object to add key-value pairs under the collection or object, if you want.
d. Click to add Node.js functions on the specified input.
e. Use the built-in functions, create your custom functions, or a combination of built-in and custom functions.
Specify your own inputs or click to map the output of any previous action as an input in the code editor.
Write custom function code, or click Functions to select any existing function, or modify an existing function.
f. Click SAVE. Custom Function is added as an input in the Value field.
g. Click to add multiple key value pairs. Click to delete any key-value pair that you added.
4. Click Done.
Output schema
Depending on key-value pairs that you provide, the Mapper action returns a dynamic output schema.
Built-in Functions in Mapper
Mapper action provides the following built-in functions (taken from the lodash library) that you can use.
Array Functions
_.Compact—Removes falsey values from the given array.
_.difference—Returns an array with values that are unique to the first array from the given number of arrays.
_.flatten—Flattens an array a single level deep.
_.flattenDeep—Flattens an entire array.
_.intersection—Returns an array with values that are common in all the given arrays.
_.first—Retrieves the first element of the given array.
_.last—Retrieves the last element of the given array.
_.uniq—Removes duplicate values from the given array.
Object Functions
_.pick—Returns an object with elements that match the specified object property.
_.get—Returns the value of an element present at the specified path in an object.
_.keys—Creates an array of the enumerable property names of an object.
String Functions
_.camelCase—Changes the string case to camelCase.
_.capitalize—Changes the first character of the string to upper case and the remaining to lower case.
_.kebabcase—Changes the string case to kebabCase.
_.lowercase—Converts the specified string to lowercase.
_.lowerfirst—Converts the first character of the string to lowercase.
_.replace—Replaces the string that match the specified condition with a particular string.
_.repeat—Repeats the given string a specified number of times.
_.trim—Removes leading and trailing whitespaces and specified characters from the given string.
_.escape—Converts the characters, &, <, >. ', and " in the given string to their corresponding HTML entities.
_.unescape—Converts the HTML entities, &amp, &lt, &gt. &quot, and &#39 in the given string to their corresponding characters.
Number Functions
_.add—Adds two numbers.
_.ceil—Rounds up the number to the specified precision.
_.divide—Divides two numbers.
_.floor—Rounds down the number to the specified precision.
_.multiply—Multiplies two numbers.
_.subtract—Subtracts two numbers.
Collection Functions
_filter—Returns the array with elements that meet the specified filter condition.
_.find—Returns the first element that meets the specified condition.
Was this helpful?