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

## Introduction

Before pushing sales orders from Shopify to NetSuite, companies and contacts must exist in both systems.

By syncing from NetSuite to Shopify first, we ensure that net terms are added to Shopify companies. This is achieved using a [cross-reference lookup](#assumptions) that maps NetSuite terms to Shopify payment terms template GIDs.

The time period for pulling new/updated data from NetSuite is set using [flow variables](#flow-variables). Companies, together with associated contacts and addresses, are compared to those in Shopify - a match is made if the company name is *exactly the same* in both systems. New companies follow one processing route and existing companies follow another:

* New companies are created using the first address, then additional locations and payment terms are added.
* Existing companies are checked for new/updated contacts, locations, and payment terms.&#x20;

## 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%2FvQSrKIYRkw5mL2AViOko%2FNetSuite%20%3E%20Shopify%20-%20create%3Aupdate%20companies%2C%20contacts%20%26%20payment%20terms%20full%20flow.png?alt=media&#x26;token=c0b972d0-8292-47e8-a608-70317aa6dba0" alt="" data-size="original">

</details>

## Limitations

<table><thead><tr><th width="316.98828125">Limitation</th><th>Summary</th></tr></thead><tbody><tr><td>Company addresses</td><td>Companies in NetSuite must have at least one address, otherwise the flow will fail.</td></tr><tr><td>Net terms</td><td>One net term is supported for each company. NetSuite does not support per-location terms (as locations are simply addresses).</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

The following cross-reference lookup tables must be updated before running this flow:

* [Net terms to payment terms template](https://doc.wearepatchworks.com/product-documentation/blueprints/patchworks-blueprints/installation-guide-shopify-and-netsuite/stage-1-patchworks-setup-shopify-and-netsuite#net-terms-to-payment-terms-template)

Please ensure that you have completed the [necessary setup](https://doc.wearepatchworks.com/product-documentation/blueprints/patchworks-blueprints/installation-guide-shopify-and-netsuite/stage-1-patchworks-setup-shopify-and-netsuite#net-terms-to-payment-terms-template) before proceeding.&#x20;

## 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>Summary</th><th>Default value</th></tr></thead><tbody><tr><td><code>datefrom</code></td><td>Sets the earliest timestamp for records to be retrieved. Update the default value as required.</td><td>-1 hour UTC</td></tr><tr><td><code>dateto</code></td><td>Sets the latest timestamp for records to be retrieved. Update the default value as required.</td><td>+0 minutes 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 %}

### 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>Notify</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 (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 (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 all companies and locations</code>       </td></tr><tr><td>Connector (Shopify)<br><br>Route: <code>New company</code> </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 Add new B2B company</code>   </td></tr><tr><td>Connector (Shopify)<br><br>Route: <code>New company</code> </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 Add new contact to company</code>   </td></tr><tr><td>Connector (Shopify)<br><br>Route: <code>New company</code> </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 Add B2B company location via graphql</code>    </td></tr><tr><td>Connector (Shopify)<br><br>Route: <code>New company</code> </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 all locations of company</code>    </td></tr><tr><td>Connector (Shopify)<br><br>Route: <code>Updated company</code> ➤ <code>New contact</code> </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 Add new contact to company</code>    </td></tr><tr><td>Connector (Shopify)<br><br>Route: <code>Updated company</code> ➤ <code>New location</code> </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 Add B2B company location via graphql</code>       </td></tr><tr><td>Connector (Shopify)<br><br>Route: <code>Updated company</code> ➤ <code>Update net terms</code></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 Update payment terms</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>Group companies</td><td>Groups the netsuite output of companies, contacts and locations.</td></tr><tr><td>NS to Shopify - Determine new or updated company</td><td>Outputs arrays for split to handle new and updated companies</td></tr><tr><td>Inject company ID into multiple contacts</td><td>To structure a company contact correctly when adding a new contact</td></tr><tr><td>Inject company ID when adding new locations</td><td>To handle multiple locations on new B2B locations</td></tr><tr><td>Split locations for payment terms</td><td>For payment terms create.</td></tr><tr><td>NS to Shopify - Determine new contact and new locations to add</td><td>Creates new contacts and creates new locations</td></tr></tbody></table>

### Cross-reference lookups in this process flow

<table><thead><tr><th width="322.93359375">Cross-reference lookup</th><th>Summary</th></tr></thead><tbody><tr><td>Net terms to payment terms template</td><td>Maps NetSuite term values to Shopify template IDs. Requires <a href="../../installation-guide-shopify-and-netsuite/stage-1-patchworks-setup-shopify-and-netsuite#net-terms-to-payment-terms-template">setup before this process flow is used</a>. </td></tr></tbody></table>
