Rule MacroRIS-RM-2317 – Shopify External Reference Update

Shopify External Reference Update

Extracts the Note value from Shopify order XML and maps it to the External Reference field while maintaining a backup and preventing duplicate updates.

Overview

The RIS-RM-2317 – Shopify External Reference Update macro automates the mapping of Shopify order notes into the External Reference field in Linnworks.

It ensures data consistency by extracting values from XML, backing up existing data, and preventing duplicate updates.

Ensure Shopify XML contains a valid <Note> node before running this macro.


Purpose

This macro:

  • Extracts Note value from Shopify XML

  • Updates External Reference field

  • Backs up existing values

  • Prevents duplicate updates

👉 In short:
Move Shopify Note → External Reference safely.


When It Runs

Executed on-demand or via automation

Typically used:

  • Shopify order processing

  • Data cleanup workflows

  • Before shipping or reporting

  • When external references are required


Parameters

path
OrderIdsstring
Required

List of order GUIDs to process.

path
SubSourcestring

Order source filter (e.g., Shopify).

Only orders matching the provided SubSource will be processed.


How It Works

Fetch Order

Retrieve order using OrderId. Skip if not found.

Validate SubSource

Check if order matches required source (e.g., Shopify). Skip if not matched.

Retrieve XML

Fetch order XML and ensure it is valid.

Parse Note Value

Extract value from <Note> node. Handle missing or invalid XML cases.

Clean Data

Trim spaces and limit value to 100 characters.

Compare Existing Value

Check if External Reference already matches extracted value. Skip if unchanged.

Backup Existing Value

Save old External Reference into order notes (if exists). Avoid duplicate backups.

Update External Reference

Set new ExternalReferenceNum and save changes.

Logging

Record skipped orders, updates, and errors for traceability.


Final Result

  • External Reference updated from Shopify XML

  • Existing values safely backed up

  • Duplicate updates prevented

  • Clean and standardized reference data

  • Full audit trail maintained


Usefulness

This macro is highly beneficial for:

  • Automating Shopify data mapping

  • Ensuring accurate external references

  • Preventing manual entry errors

  • Maintaining data history and traceability

  • Supporting downstream integrations


Important Notes

  • Works only if XML contains valid <Note> node

  • External Reference is limited to 100 characters

  • Orders not matching SubSource are skipped

  • Duplicate values are not updated again

  • Backup notes are added only when needed

  • Invalid XML will result in skipped processing


Example Scenario


Key Insight

This macro enables seamless XML-to-field mapping between Shopify and Linnworks.
By combining validation, comparison, and backup logic, it ensures reliable data updates, prevents duplication, and preserves historical values for audit and tracking.