# Shopify > NetSuite - order refunds

## Introduction

A GraphQL query searches for orders in Shopify that were last modified after a given date, and are in a `refunded` state. The lookback date is calculated by referencing a `date` [flow variable](#flow-variables) in the `updated_at` section of the GraphQL query. &#x20;

The flow then searches for matching orders in NetSuite (using the order name), retrieving order details and order lines.&#x20;

After this, a script determines which specific lines are being refunded by matching the return lines with their SKUs. It then creates an RMA (*Return Merchandise Authorisation*) from the sales order, followed by a credit memo.

{% hint style="info" %}
The [manual payload](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/manual-payload-shape) before the credit memo contains `{}` - this triggers the RMA ➤ credit memo conversion. The [set variables shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/set-variables-shape) sets a meta variable for `rmaid` , with the value derived from incoming Netsuite RMA IDs - this fully converts the RMA into a credit memo.
{% endhint %}

## 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%2F8HX40AQ8wKHvqRlLVuVQ%2FShopify%20%3E%20NetSuite%20-%20order%20refunds%20full%20flow.png?alt=media&#x26;token=dc35148e-b0bd-4bd8-a9e2-2a8c8cac73c7" alt="" data-size="original">

</details>

## Limitations

<table><thead><tr><th width="266.79296875">Limitation</th><th>Summary</th></tr></thead><tbody><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

There are no assumptions to note for this flow.

## 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>-30 minutes</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><p>The default schedule is set to run every <code>30 minutes</code>. You can edit this shape and define your preferred run schedule. </p><p><br>Keep in mind that the GraphQL query on the first Shopify connector retrieves orders that have been updated since your given lookback period (based on the value of the <code>date</code> <a href="#flow-variables">flow variable</a>). Ensure that the trigger schedule aligns with your lookback period.</p></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 refunded 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)</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 Create RMA from sales order via transform</code>  </p><p><code>Variables</code>: Leave <code>NetSuite Sales Order ID</code> as the default.</p></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 Create credit memo from RMA via transform</code>  </p><p><code>Variables</code>: Leave <code>NetSuite RMA ID</code> as the default.</p></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 refund lines for Netsuite</td><td>Checks order lines to determine what lines are needed for the refund.</td></tr><tr><td>Pull Netsuite ID from RMA header</td><td>Pulls the NetSuite ID from response so it can be used again.</td></tr></tbody></table>

### Cross-reference lookups in this process flow

This process flow does not use cross-reference lookups.
