# Shopify > NetSuite - sales order creation

## Introduction

This flow retrieves orders from Shopify that were created in a `paid` or `pending` state, based on the order's financial status. Depending on this state, orders are sent down one of two branches:

* **Paid orders**. The order is created in NetSuite against the relevant company, then a customer deposit is applied, and an invoice is raised.
* **Unpaid orders**. The order is created in NetSuite against the relevant company, but no documents are created (payment can be made through NetSuite when ready).&#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%2F3DazDrGLhwYXTJxutibB%2FShopify%20%3E%20NetSuite%20-%20sales%20order%20creation%20full%20flow.png?alt=media&#x26;token=767a47a6-5497-434f-8cdc-f26784a7ef19" alt="" data-size="original">

</details>

## Limitations

<table><thead><tr><th width="316.98828125">Limitation</th><th>Summary</th></tr></thead><tbody><tr><td>One <code>subsidiary ID</code> is supported.</td><td>You must apply the required ID before running this flow - please see <code>Customisation</code> ➤ <code>Process flow shapes</code> for more information.</td></tr><tr><td>This flow expects new orders </td><td>This flow does not support updating existing orders.</td></tr><tr><td> Cash sales are not supported.</td><td>N/A</td></tr><tr><td>Order details</td><td>Mappings are defined for standard orders. If required, mappings can be added for more complex orders (e.g. discounts and gift cards).</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

* Companies must be synced in both systems (see [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) and [Shopify > NetSuite - create/update companies, locations & contacts](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)).
* Products must be synced in both systems (see [Shopify > NetSuite - create & update products](https://doc.wearepatchworks.com/product-documentation/blueprints/patchworks-blueprints/shopify-and-netsuite/available-process-flows-shopify-and-netsuite/shopify-greater-than-netsuite-create-and-update-products)).
* The following cross-reference lookup tables must be updated before running this flow: [Shopify location > NetSuite location ID](https://doc.wearepatchworks.com/product-documentation/blueprints/patchworks-blueprints/installation-guide-shopify-and-netsuite/stage-1-patchworks-setup-shopify-and-netsuite#shopify-location-greater-than-netsuite-location-id). 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#shopify-location-greater-than-netsuite-location-id) before proceeding.&#x20;
* NetSuite permissions are required to create invoices, customer deposits, and the ability to create invoices without fulfilment (see [Installation ➤ Stage 2: NetSuite prerequisites](https://doc.wearepatchworks.com/product-documentation/blueprints/patchworks-blueprints/shopify-and-netsuite/installation-guide-shopify-and-netsuite/stage-2-netsuite-prerequisites-shopify-and-netsuite)). &#x20;
* Your NetSuite `subsidiary ID` must be applied before running this flow.  - please see `Customisation` ➤ `Process flow shapes` for more information.
* This flow assumes that SKUs are stored in NetSuite's `upccode` field. If you use a different field to store this value, any connector queries, mappings and scripts referencing the `upccode` field must be updated. Please see the [Customisation ➤ process flow shapes](#process-flow-shapes) section for details.

## 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>date</code></td><td>Set the relative time period to look back for new orders in Shopify. Update the default value as required.</td><td>-1 minute</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 (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 orders via graphql</code><br><code>Variables</code> : Leave the <code>filter</code> variable as it defaults. This variable references your <code>date</code> flow variable to determine the lookback period for new orders. Make sure this <a href="#flow-variables">flow variable</a> is set as required.</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:</p><p></p><p><code>Source instance</code>: Set to your required <code>NetSuite</code> instance.</p><p><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>Paid orders</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>: SuiteQL compares SKUs to a value in NetSuite. This NetSuite connector is configured with a query that expects the comparison value in <code>upccode</code>. If you use a different field, please update the query accordingly.</p></td></tr><tr><td>Connector (Shopify)<br><br>Route: <code>Paid orders</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 fulfillment location of order via graphql</code> <br><code>Variables</code> : Leave the <code>order ID</code> variable as it defaults. </td></tr><tr><td>Map<br><br>Route: <code>Paid orders</code></td><td><p>You must update the custom string transform function associated with the subsidiary.id mapping rule:</p><p></p><p><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FGdcwKZc9Wxpci8JZ9MjQ%2Fsubsidiary%20id%20mapping%20rule.png?alt=media&#x26;token=474f0e1c-645b-4669-a042-db38b0e0ce3f" alt=""><br><br>For more information about working with the custom string transform documentation, please see our <a href="../../../../process-flows/building-process-flows/process-flow-shapes/standard-shapes/map-shape/working-with-field-transformations/available-transform-functions/string-transform-functions/custom-string-transform-function">custom string</a> documentation.</p></td></tr><tr><td>Connector (NetSuite)<br><br>Route: <code>Paid orders</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 sales order</code><br><br><br></td></tr><tr><td>Connector (NetSuite)<br><br>Route: <code>Paid orders</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 deposit</code> </td></tr><tr><td>Connector (NetSuite)<br><br>Route: <code>Paid orders</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 transform SO into invoice</code>     </td></tr><tr><td>Connector (NetSuite)<br><br>Route: <code>Unpaid orders</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>: SuiteQL compares SKUs to a value in NetSuite. This NetSuite connector is configured with a query that expects the comparison value in <code>upccode</code>. If you use a different field, please update the query accordingly.</p></td></tr><tr><td>Connector (Shopify)<br><br>Route: <code>Unpaid orders</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 fulfillment location of order via graphql</code> <br><code>Variables</code> : Leave the <code>order ID</code> variable as it defaults. </td></tr><tr><td>Map<br><br>Route: <code>Unpaid orders</code></td><td><p>You must update the custom string transform function associated with the subsidiary.id mapping rule:</p><p></p><p><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FK6knlBo7s6HNFSYC7knK%2Funpaid%20subsidiary%20id%20mapping%20rule.png?alt=media&#x26;token=651b0975-b2ab-49fc-8c6a-c1c23c2fd401" alt=""><br><br>For more information about working with the custom string transform documentation, please see our <a href="../../../../process-flows/building-process-flows/process-flow-shapes/standard-shapes/map-shape/working-with-field-transformations/available-transform-functions/string-transform-functions/custom-string-transform-function">custom string</a> documentation.</p></td></tr><tr><td>Connector (NetSuite)<br><br>Route: <code>Unpaid orders</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 sales order</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> Add single quotes to products</td><td>Adds single quotes to products so they can be searched correctly in Netsuite.</td></tr><tr><td> Merge NS ID to line items</td><td>Pushes the NetSuite ID into line items from the previous payload for cleaner mapping.</td></tr><tr><td> Pulls SO ID from header</td><td>Pulls the NetSuite order ID from the header so it can be used again.</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>Shopify location > Netsuite Location ID</td><td>Maps locations from Shopify to NetSuite. Requires <a href="../../installation-guide-shopify-and-netsuite/stage-1-patchworks-setup-shopify-and-netsuite#shopify-location-greater-than-netsuite-location-id">setup before this process flow is used</a>. </td></tr></tbody></table>
