Articles in this section

Example: Look up a NetSuite customer and merge the result

This example builds a flow that imports a Shopify customer into NetSuite, looks up the customer's parent company in NetSuite, and uses the parent company to create a sales order. Use it to see how a response mapping feeds a lookup, and how a results mapping brings the lookup data back. It's for builders who work with NetSuite saved searches.

The flow has these steps:

  1. Export a customer record from Shopify.
  2. Import the customer into NetSuite.
  3. Look up the customer's parent company in NetSuite.
  4. Import a sales order for the parent company into NetSuite.
  5. Import the errors from the sales order step.

Save the new customer's internal ID

After the NetSuite customer import, add a response mapping that saves the new customer's internal ID.

  1. On the customer import step, open the response mapping. To do this, see Configure response mapping.
  2. Map id to a source field named netsuite_id.

The source record now has a netsuite_id field that later steps can use. To confirm, check that netsuite_id appears as a source field in the next step's mapping, or review the record as retry data when a later step fails.

Configure the lookup

A NetSuite lookup runs a saved search that you create in NetSuite. In this example, the search returns all customers, and the lookup narrows the results to the customer you created.

  1. In NetSuite, create the saved search.
  2. In the lookup step, set Record type to Customer.
  3. Set Saved search type to Public or Private, to match the saved search in NetSuite, and then enter the saved search's ID in Search internal ID.
  4. Under Additional search criteria, select Launch, and add a criterion that matches the internal ID to a handlebars expression for netsuite_id. integrator.io fills in the value for each record.

You can add more criteria. They're joined with AND, so a record must match all of them for the saved search to return it.

To refresh the field labels after you rename a field in NetSuite, go to Resources resources-icon.png, and then select Connections. In the row for the NetSuite connection, select More elipses-button.png > Refresh metadata.

For lookups on most other applications, put the handlebars expression in the Relative URI instead of a saved search. For example, a lookup against a shipping provider can pass a purchase order ID in the URI so the ID changes for each order.

Merge the parent company ID

Add a results mapping to the lookup. To do this, see Configure results mapping.

The saved search returns one record for each internal ID, so map data[0]. This example uses a custom label, parent_id, in the saved search results for the parent company's internal ID. The mapping adds the parent company's ID to the source record.

The sales order import can now use that field. Map it, and any other required Shopify fields, in the import mapping. To open the mapping, see Configure import mapping in Mapper 1.0.

Capture errors in a custom record or file

You can review import errors on the integration dashboard. To also write them to a custom record in NetSuite, or to a CSV file on an FTP server, add a response mapping that saves the errors to the source record, and then add a step that imports them.

  1. On the sales order import step, add a response mapping.
  2. Map errors to a source field named so_errors.

Each error that the sales order import returns is written to so_errors on the source record. The final import step sends that field to the custom record or file.