# Shopify > Brightpearl - company and contact update/create

## Introduction

This flow retrieves company, contact and location details from Shopify and creates/updates correlating details in Brightpearl.

## 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>

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FMa0ZsenwTJoUz5sfbHhr%2FShopify%20%3E%20Brightpearl%20-%20company%20and%20contact%20update%3Acreate%20-%20full%20flow.png?alt=media&#x26;token=83efe02b-808b-402b-b2de-0ce4c0cd6129" alt=""><figcaption></figcaption></figure>

</details>

## Limitations

No limitations to note.

## Assumptions

<table><thead><tr><th width="266.79296875">Assumption</th><th>Summary</th></tr></thead><tbody><tr><td>Sync direction</td><td>Running this flow assumes that you want to sync data in this direction (i.e. from Shopify to Brightpearl). If required, a flow for the reverse direction is<a href="shopify-greater-than-brightpearl-fulfillment"> </a>available (<a href="brightpearl-greater-than-shopify-create-update-companies-contacts-and-payment-terms">Brightpearl > Shopify - create/update companies, contacts &#x26; payment terms</a>). You should run one or the other.</td></tr></tbody></table>

## 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>datesince</code></td><td>Set the relative number of days to look back for updates. Update the default value as required.<br><br>This variable is referenced in the first map shape in the flow, where a <code>custom string</code> transform passes the lookback value into the subsequent Shopify query.</td><td>-4 hours 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="230.578125">Shape</th><th>Notes</th></tr></thead><tbody><tr><td>Trigger</td><td>The default schedule for this flow is to run <code>every 4 hours at 0 minutes past the hour</code>. This is the recommended run frequency but the schedule can be changed if necessary.</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-brightpearl">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</code><br><code>Updated since</code> : Set to <code>[[payload.lookback]]</code> </td></tr><tr><td>Connector (Brightpearl)</td><td>If you did not add or select a Brightpearl instance during the blueprint <a href="../installation-guide-shopify-and-brightpearl">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Brightpearl</code> instance.<br><code>Source endpoint</code> :  Set to <code>GET Search company</code><br><code>Parameter</code> : Filter defined to retrieve only companies where the <code>name</code> field is set to <code>[[payload.company_name]]</code>. </td></tr><tr><td>Connector (Brightpearl)<br>branch: <code>new company</code><br>➤ branch: <code>first branch</code><br><br></td><td>If you did not add or select a Brightpearl instance during the blueprint <a href="../installation-guide-shopify-and-brightpearl">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Brightpearl</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Create new locations</code></td></tr><tr><td>Connector (Brightpearl)<br>branch: <code>new company</code><br>➤ branch: <code>second branch</code><br><br></td><td>If you did not add or select a Brightpearl instance during the blueprint <a href="../installation-guide-shopify-and-brightpearl">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Brightpearl</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Create new contacts</code></td></tr><tr><td>Connector (Brightpearl)<br>branch: <code>new company</code><br>➤ branch: <code>new branch</code><br><br></td><td>If you did not add or select a Brightpearl instance during the blueprint <a href="../installation-guide-shopify-and-brightpearl">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Brightpearl</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Create company locations to company ID</code>    </td></tr><tr><td>Connector (Brightpearl)<br>branch: <code>update company</code><br>➤ branch: <code>create location ids</code></td><td>If you did not add or select a Brightpearl instance during the blueprint <a href="../installation-guide-shopify-and-brightpearl">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Brightpearl</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Create new locations</code>    </td></tr><tr><td>Connector (Brightpearl)<br>branch: <code>update company</code><br>➤ branch: <code>new contacts</code></td><td>If you did not add or select a Brightpearl instance during the blueprint <a href="../installation-guide-shopify-and-brightpearl">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Brightpearl</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Create new contacts</code>    </td></tr><tr><td>Connector (Brightpearl)<br>branch: <code>update company</code><br>➤ branch: <code>assign location id to company</code>   </td><td>If you did not add or select a Brightpearl instance during the blueprint <a href="../installation-guide-shopify-and-brightpearl">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Brightpearl</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Create company locations to company ID</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>Brightpearl - determine new or current companies</td><td>Checks if the company is new or already exists in Brightpearl.</td></tr><tr><td>Brightpearl - create array of addresses</td><td>Put Shopify addresses into an array.</td></tr><tr><td>New company - assign location IDs to contacts</td><td>Assign location IDs (from location creation) to the contacts.</td></tr><tr><td>BP - new contact update locations</td><td>Adds contact IDs to locations.</td></tr><tr><td>Brightpearl - determine new contacts and new locations</td><td>Checks new contacts and locations for existing companies in Brightpearl.</td></tr><tr><td>Assign location IDs to contacts</td><td>Adds location IDs to new contacts for existing companies.</td></tr><tr><td>Determine id map for location add</td><td>Transforms location data and associates location ids.</td></tr></tbody></table>

### Cross-reference lookups in this process flow

This process flow does not use cross-reference lookups.
