For flows that have multiple imports, response mappings allow you to define actions based on the API response from an import. For example, you can use response mapping to define an action based on the success or fail value of a field for records sent to an import.
Results mappings merge data returned from a lookup into the original export’s data, so that the new data can be used in steps later on in the flow. For lookups, if you have Shopify customers that require the creation of sales orders from various other parent companies that can already be assigned by customer region in NetSuite, those parent companies are only accessible in the flow with a lookup step and response mappings.
The above example uses the following steps:
- Export a customer record from Shopify.
- Import the record into NetSuite.
- Use a lookup to find the customer's parent company in NetSuite.
- Perform another import to create a sales order for the parent company in NetSuite.
- Perform a final import step to catch errors.
Note: If you rename a field label in NetSuite and want to reflect the same label name in integrator.io, refresh the metadata on your connection and check the mapping field. To refresh metadata, go to Connections > NetSuite Connection > Actions > Refresh metadata.
- Configure response mappings
- Retrieve customer ID
- Configure lookup
- Catch errors
- Additional lookup steps
Once you import the customer into NetSuite for the first time, configure the response mappings. Click the mappings () button immediately after the import step to create or modify response mappings. Click + within the step to add it if it isn’t visible.
The response mappings for NetSuite imports allow the following options:
- id: exports the internal ID of the record just imported into NetSuite.
- errors: exports any errors from the processed record in this step.
- ignored: exports a “true” or “false” value. The value is "true" if the record processed through this import step was ignored. Otherwise the value is "false".
- statusCode: exports the status code that resulted from processing the record through this import step.
All of this data is merged into the source data as new fields (or replaces existing fields). Choose a field from the Source record field on the right to hold the values that will be merged back into the source data for use later on in the flow. If you use a name that is already a field on the top level of the source data’s JSON object, response mapping overwrites that field. If you use a new name, a new field is added to the source data.
Response mapping for imports into other endpoints (besides NetSuite) may have more options than the record ID available depending on the data fields of the endpoint. Some APIs return the whole object you just imported back to you, and some only give an ID (like NetSuite). If any other fields return when importing a record in the API, you can manually add that field on the left, but it won’t appear in the drop-down menu. For example, HubSpot returns a companyId field when creating a company through the company's API, and a response mapping can be added as shown in the following image.
The next step in this example retrieves the ID of the imported customer and stores it in a field named "netsuite_id" for use in the following lookup step:
This adds a “netsuite_id” field onto the original export of the Shopify customer. The following image displays the JSON structure for each JSON object of the imported customer (omitting much of the data to see the bottoms of the objects):
To verify that the JSON picked up the response mapping in the next step in the flow, you can examine the new JSON data as retry data when the flow errors in further steps. Also, the response mapping should show up in a drop-down menu in the next import step’s mappings.
NetSuite lookup steps require you to create a saved search within NetSuite. In this case, the search retrieves all customers, and then uses the "netsuite_id" from the previous step to find the customer that was just created with that internal ID.
- Set up the saved search in NetSuite, and add it to the lookup step.
- Set the Record type to Customer.
- Set the Saved search type to Public or Private depending on how you've configured it in NetSuite
- Click Launch under Additional search criteria and use a handlebars expression on the NetSuite internal ID. The handlebars expression populates the ID field value for each record imported.
Lookup steps always require results mappings to merge the lookup data into the source data for use later in the flow. Lookups differ from import steps in that they have one additional data option for results mappings.
The data option returns an array of objects: one for each record the “All Customers” search retrieves. But since the search only retrieves a specific internal ID, there should only be one result returned per lookup. The lookup step also adds a new field back onto each record of source data. The saved search for “All Customers” returns the results for a single record in an array.
You can access all items in the array with data. data is bracket notation that selects the first item of the data array. If more than one record returns in a lookup step, select data from the drop-down menu rather than data, so that the newly created field contains multiple objects rather than a single object. You can then target the field in further steps with normal JSON arrays in integrator.io.
In this case, the data option should only return one value (the parent company's ID). This example uses a custom label (parent_id) in the saved search results.
This gets the NetSuite internal ID of the related parent company to the originally exported customer, and adds it back onto the JSON data like before. Now, you can use this data in the following import step’s mappings:
Here you can also map whatever other required information is needed from the original Shopify export to create a sales order successfully.
Using the above mapping will cause errors. Errors don’t usually require response mappings because they can be reviewed and resolved on the integration dashboard, but if you want to import errors into a custom record in NetSuite (or in a CSV file in an FTP), you must configure response mappings.
Each error the sales order import encounters is written to a new field called “so_errors”.
The errors will be merged into the original object in the “so_errors” field.
You can also configure an unlimited number of further lookup or import steps with response mappings as needed to use in further steps.
Pause here until someone can fix the error
When a record causes an error, by default, the Pause here until someone can fix the error option is selected to stop the flow from sending the failed record to any subsequent flow steps until the error is fixed. The failed record will be held here so that you can fix and retry it. Upon a successful retry, the record will then proceed to any additional flow steps.
Proceed to the next application regardless
Click Proceed to the next application regardless to push records that contain errors to subsequent flow steps regardless of whether or not the record produces an error during this flow step. The failed record can still be fixed and retried for this flow step, but if it didn't fail on any additional flow steps, it won't be pushed to those additional steps upon successful retry. This is the preferred choice if, for example in NetSuite use cases, you are sending inventory update records to multiple webstores or marketplaces. If the record fails on this step, you might still want that record to proceed to any subsequent steps in the flow so that the other stores and marketplaces can get the update.
In additional lookup steps, the data will be merged into the original export in whatever field name you choose to store the values in (merging both the customer ID from an import and the parent_id from an export into the source data for use in further steps in the flow).
One difference for HTTPS lookups (and lookups for most other APIs besides NetSuite) is that the lookup step’s variable is often placed in the relative URI instead of a saved search.
This is an example configuration of sales orders exported by NetSuite with a Shipwire lookup to capture order information within Shipwire:
In this case, the handlebars statement is put within the parameters of the API call, and the purchase order ID changes dynamically for each order processed by the flow.