# Shopify > NetSuite - create/update companies, locations & contacts

## Introduction

Before pushing sales orders from Shopify to NetSuite, companies and contacts must exist in both systems. Running the [NetSuite > Shopify - create/update companies, contacts & payment terms](https://doc.wearepatchworks.com/product-documentation/blueprints/patchworks-blueprints/shopify-and-netsuite/available-process-flows-shopify-and-netsuite/netsuite-greater-than-shopify-create-update-companies-contacts-and-payment-terms) flow first ensures that companies are synced with payment terms. Thereafter, this flow can be run to update NetSuite with new/updated companies in Shopify.

{% hint style="warning" %}
The `Shopify > NetSuite - create/update companies, locations & contacts` flow does NOT sync payment terms.&#x20;
{% endhint %}

Having received company details from Shopify and NetSuite, a script compares the two sets of data to determine new and updated records for NetSuite.&#x20;

Companies are matched based on the company name. If an exact match is NOT found, the company is considered new; if an exact match IS found, the company exists. New companies follow one processing route and existing companies follow another:&#x20;

* New companies are created ( 'customers' are configured to be companies), followed by contacts, and finally, locations.
* Existing companies are updated with new addresses and/or new contacts - updating existing addresses is not supported.

The time period for pulling new/updated data from Shopify is set using a [flow variable](#flow-variables). This value is passed into a Shopify variable via a mapping transform function. For more information, please refer to  [How the lookback period is set](#how-the-lookback-period-is-set).

## Process flow snapshot

<details>

<summary><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FSUvxsp8XwrC9qsafJMIe%2Ficon%20process%20flow.svg?alt=media&#x26;token=ad1dc886-4a4e-4cad-9ad0-3d755e0f3b5a" alt="" data-size="line"> Click to view process flow snapshot</summary>

<img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2Fl4z1x1qQDfKdmIL6D8Fr%2FShopify%20%3E%20NetSuite%20-%20create%3Aupdate%20companies%20%26%20contacts%20full%20flow.png?alt=media&#x26;token=afe280a9-9454-4644-a742-874fe0752fd4" alt="" data-size="original">

</details>

## Limitations

<table><thead><tr><th width="316.98828125">Limitation</th><th>Summary</th></tr></thead><tbody><tr><td>Payment terms</td><td>Payment terms are not synced from Shopify to NetSuite (they are synced from <a href="netsuite-greater-than-shopify-create-update-companies-contacts-and-payment-terms">NetSuite to Shopify</a>).</td></tr><tr><td>Addresses</td><td>For existing companies, new addresses are added but existing addresses are not updated. </td></tr><tr><td>Shopify GraphQL error handling</td><td>There is a known limitation with error handling for Shopify GraphQL. Please refer to the <a href="../../installation-guide-shopify-and-netsuite/stage-5-review-update-and-test-process-flows-shopify-and-netsuite#error-handling-for-shopify-graphql">Error handling for Shopify GraphQL</a> section for more information and a suggested approach that you may wish to adopt in your flows. </td></tr></tbody></table>

## Assumptions

No assumptions to note.

## Customisation

To ensure that this process flow runs as required, some customisation options are available. These are documented in the following sections:

* [Flow variables](#flow-variables)
* [Process shape shapes](#process-flow-shapes)

### Flow variables

The table below summarises [flow variables](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/dynamic-variables/flow-variables) defined for this process flow.

<table><thead><tr><th width="163.5078125">Flow variable</th><th width="373.32421875">Summary</th><th>Default value</th></tr></thead><tbody><tr><td><code>datesince</code></td><td>Sets a date and time relative to the given period. This is used to calculate the lookback period for company updates. Update as required. <br><br>For more information, please refer to  <a href="#how-the-lookback-period-is-set">How the lookback period is set</a>.</td><td>-1 hour UTC</td></tr></tbody></table>

{% hint style="info" %}
For information on working with flow variables, please refer to our [flow variables documentation](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/dynamic-variables/flow-variables).
{% endhint %}

## How the lookback period is set

When retrieving company data from Shopify, the lookback period is determined as follows:

1. The relative date [flow variable](#flow-variables) named `datesince` is defined with a lookback time period (the default setting is `-360 minutes`).
2. A map shape outputs the `datesince` (relative date) value as a custom string and converts this to an ISO date format. &#x20;
3. The relative date is passed into the Shopify connector shape.
4. The Shopify connector shape requests company details, passing in the relative date as a variable value (in the connector shape, this variable is displayed `Updated Since` but its key is `timestamp`). &#x20;
5. The GraphQL query for the request endpoint includes constraints for `timestamp`.&#x20;

### Process flow shapes

This process flow includes some shapes that can be configured with your own settings. Please see guidelines in the table below.

{% hint style="warning" %}
Shape settings determine the outcome of process flows. Do not change shape settings unless they are listed below.&#x20;
{% endhint %}

<table data-full-width="false"><thead><tr><th width="165.34375">Shape</th><th>Notes</th></tr></thead><tbody><tr><td>Trigger</td><td>The default setting is to run hourly, which is recommended. You can change the schedule if required. Keep in mind that <a href="#flow-variables">flow variables</a> determine the lookback period, so these settings should align. </td></tr><tr><td></td><td>This flow is designed in a try/catch structure, so notifications are generated if any part of the flow fails. To achieve this, the <code>catch</code> route includes a <a href="../../../../process-flows/building-process-flows/process-flow-shapes/standard-shapes/notify-shape">notify shape</a>, which must be configured for your own notification preferences. <br><br><code>Alert level</code>: Defaults to <code>error</code> but can be changed if needed<br><code>Channel</code>: Defaults to <code>email + log</code> but can be changed if needed<br><code>Email Limit</code>: Defaults to <code>5</code> but can be changed if needed<br><code>Notification Group</code>: Replace the <code>notify</code> placeholder which your required notification group. <br><code>Message</code>: If required, you can change the placeholder message.<br><br>For more information please refer to our <a href="../../../../process-flows/building-process-flows/process-flow-shapes/standard-shapes/notify-shape">Notify shape</a> and <a href="../../../../general-settings/notification-groups">Notification groups</a> pages.</td></tr><tr><td>Connector (Shopify)</td><td>If you did not add or select a Shopify instance during the blueprint <a href="../installation-guide-shopify-and-netsuite/stage-4-install-the-blueprint-shopify-and-netsuite">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Shopify</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Get updated companies and contacts V2</code>       </td></tr><tr><td>Connector (NetSuite)</td><td><p>If you did not add or select a NetSuite instance during the blueprint <a href="../installation-guide-shopify-and-netsuite/stage-4-install-the-blueprint-shopify-and-netsuite">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>NetSuite</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST suiteQL</code></p><p><code>Query</code>: Leave as the default</p></td></tr><tr><td>Connector (NetSuite)<br><br>Route: <code>New company</code> </td><td>If you did not add or select a NetSuite instance during the blueprint <a href="../installation-guide-shopify-and-netsuite/stage-4-install-the-blueprint-shopify-and-netsuite">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>NetSuite</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Create Customer</code>       </td></tr><tr><td>Connector (NetSuite)<br><br>Route: <code>New company</code> </td><td>If you did not add or select a NetSuite instance during the blueprint <a href="../installation-guide-shopify-and-netsuite/stage-4-install-the-blueprint-shopify-and-netsuite">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>NetSuite</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Create Contact</code>       </td></tr><tr><td>Connector (NetSuite)<br><br>Route: <code>New company</code>  </td><td>If you did not add or select a NetSuite instance during the blueprint <a href="../installation-guide-shopify-and-netsuite/stage-4-install-the-blueprint-shopify-and-netsuite">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>NetSuite</code> instance.<br><code>Source endpoint</code> :  Set to <code>PATCH Update company address</code>       </td></tr><tr><td> Connector (NetSuite)<br><br>Route: <code>Update company</code> </td><td><p>If you did not add or select a NetSuite instance during the blueprint <a href="../installation-guide-shopify-and-netsuite/stage-4-install-the-blueprint-shopify-and-netsuite">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>NetSuite</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST suiteQL</code></p><p><code>Query</code>: Leave as the default</p></td></tr><tr><td>Connector (NetSuite)<br><br>Route: <code>Update company</code> ➤ <code>First branch</code></td><td>If you did not add or select a NetSuite instance during the blueprint <a href="../installation-guide-shopify-and-netsuite/stage-4-install-the-blueprint-shopify-and-netsuite">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>NetSuite</code> instance.<br><code>Source endpoint</code> :  Set to <code>PATCH Update company address</code>       </td></tr><tr><td>Connector (NetSuite)<br><br>Route: <code>Update company</code> ➤ <code>First branch</code></td><td>If you did not add or select a NetSuite instance during the blueprint <a href="../installation-guide-shopify-and-netsuite/stage-4-install-the-blueprint-shopify-and-netsuite">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>NetSuite</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Create Contact</code>       </td></tr></tbody></table>

## Reference

Reference information for this process flow is documented in the following sections:

* [Scripts used in this process flow](#scripts-in-this-process-flow)
* [Cross-reference lookups used in this process flow](#cross-reference-lookups-in-this-process-flow)

### Scripts in this process flow

<table><thead><tr><th width="293">Script</th><th>Summary</th></tr></thead><tbody><tr><td> Determine new or current company</td><td> For branching out the companies.</td></tr><tr><td> Output new company ID</td><td> Extracts and outputs the NS ID of the new company.</td></tr><tr><td> Add a Random Sleep</td><td> Adds a random sleep for 1 to 5 seconds.</td></tr><tr><td>Determine new contacts and locations v3</td><td> Determine new contacts and locations.</td></tr></tbody></table>

### Cross-reference lookups in this process flow

No cross-reference lookups to note.
