# 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](/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.md) 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="/files/y1IE71BfODU6ZRj1HNMM" alt="" data-size="line"> Click to view process flow snapshot</summary>

<img src="/files/XdHRK466a53ox27urz7L" 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="/pages/z4WHNuaEGoXZeTasA89h">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="/pages/cAsDFgC7o0rXqfyJWolv#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](/product-documentation/process-flows/building-process-flows/dynamic-variables/flow-variables.md) 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](/product-documentation/process-flows/building-process-flows/dynamic-variables/flow-variables.md).
{% 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="/pages/qJOdm6pHm3I8Ovog6Ola">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="/pages/qJOdm6pHm3I8Ovog6Ola">Notify shape</a> and <a href="/pages/ul3TLNVYRLYUGugTOFLU">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="/pages/ZuNUyYvEy14sajACk8N9">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="/pages/ZuNUyYvEy14sajACk8N9">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="/pages/ZuNUyYvEy14sajACk8N9">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="/pages/ZuNUyYvEy14sajACk8N9">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="/pages/ZuNUyYvEy14sajACk8N9">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="/pages/ZuNUyYvEy14sajACk8N9">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="/pages/ZuNUyYvEy14sajACk8N9">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="/pages/ZuNUyYvEy14sajACk8N9">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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.wearepatchworks.com/product-documentation/blueprints/patchworks-blueprints/shopify-and-netsuite/available-process-flows-shopify-and-netsuite/shopify-greater-than-netsuite-create-update-companies-locations-and-contacts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
