Schedule MacroRIS-SM-1033 Auto Archive Inventory

Auto Archive Inventory

Automatically archive Linnworks inventory items where the SKU/item number contains a configured prefix, suffix, or matching text value.

Archiving inventory items manually can be time-consuming when a large number of SKUs need to be removed from active inventory views. The Inventory Archiving by SKU Match macro helps automate this process by searching inventory item numbers for a configured text value and archiving all matching stock items.

This macro is useful when your team needs to archive products that share a common SKU pattern, prefix, suffix, or keyword.

The macro searches the Linnworks stockitem table for item numbers that contain the configured suffixOrPrefix value, collects the matching stock item IDs, and sends them to the Linnworks Inventory API for archiving.

Archive matching inventory items automatically by using a configured SKU text match.

Configure the Macro

Once the app is installed, you need to set up the macro configuration so the system knows which SKU text value should be used when searching for inventory items to archive.

This setup can be adjusted anytime based on your operational requirements.

Steps to Configure

Go to Apps > Macro Configuration and click + Add new configuration.

Key Benefits

Archiving inventory items by SKU pattern can be repetitive when done manually. This macro helps automate the process by searching for matching item numbers and archiving the matching inventory records in bulk.

How It Works

The macro searches for stock items where the item number contains the configured text value, then archives the matching inventory items.

Step 1

The macro starts execution and writes Inventory archiving macro started to the log.

Step 2

The macro receives the configured suffixOrPrefix parameter value.

Step 3

It builds a custom SQL query to search the stockitem table for item numbers that contain the configured value.

Step 4

The macro executes the custom script query using the Linnworks Dashboards API.

Step 5

If the query completes without error and returns results, the macro loops through the returned rows.

Step 6

Each returned stock item ID is converted to a GUID and added to the archive list.

Step 7

The macro creates an InventoryParametersRequest containing the matching stock item IDs.

Step 8

The macro calls ArchiveInventoryItems to archive the matching inventory items.

Step 9

If an error occurs, the macro logs the error message.

Step 10

The macro writes Inventory archiving macro finished when execution ends.

Usage of App

This macro is designed to archive inventory items automatically using a configured SKU text match. It is useful when products need to be archived in groups based on a common item number pattern.

suffixOrPrefix

Defines the text value used to search inventory item numbers. Any inventory item number containing this value is included in the archive list.

Stock Item Query

The macro searches the stockitem table for matching item numbers using a query based on the configured suffixOrPrefix value.

Matching Stock Item IDs

The macro collects the pkStockItemId values returned from the query and uses them as the inventory item IDs to archive.

Archive Inventory Items

Matching inventory items are archived using the Linnworks Inventory API.

Execution Logging

The macro records the start, errors, and completion of the process using the macro logger.

Key Points to Remember

  • The macro uses the suffixOrPrefix parameter to search item numbers

  • The search checks whether the item number contains the configured value

  • The search is not limited to only the start or end of the item number

  • Matching stock item IDs are archived in bulk

  • The macro uses a custom script query to find matching stock items

  • The macro archives items using Api.Inventory.ArchiveInventoryItems

  • The macro does not preview the matching items before archiving

  • The macro does not add notes to inventory items

  • The macro does not check whether items are already archived before sending them to the archive request

  • The macro logs errors and completion status

Important: Review the configured suffixOrPrefix value carefully before running the macro. A broad value may match and archive more inventory items than intended.

Important: Avoid using commas, quotes, wildcards, or special SQL characters in the parameter value unless the macro code has been updated to handle them safely.

What You Can Expect

  • Matching inventory items are archived
    Any stock item where the item number contains the configured suffixOrPrefix value is included in the archive request.

  • Multiple items can be archived in one run
    If several SKUs match the configured value, all matching stock item IDs are sent to the archive API.

  • No matching items means no items are archived
    If the query returns no results, the archive list remains empty.

  • Execution is logged
    The macro records when it starts, finishes, and if an error occurs.

  • The process is based on item number matching
    The macro does not check product title, barcode, category, supplier, or other inventory fields.

Overall Impact

This macro helps simplify inventory cleanup by automatically archiving stock items that match a configured SKU text pattern. It reduces manual effort and helps teams remove groups of discontinued, old, or unwanted items from active inventory views.

What To Do After the Macro Runs

After the macro has completed, review the affected inventory items to confirm that the correct SKUs were archived.

Steps to Follow

Step 1

Open Linnworks and go to the inventory area.

Step 2

Search for SKUs containing the configured suffixOrPrefix value.

Step 3

Confirm that the intended matching inventory items have been archived.

Step 4

Check that no unintended SKUs were matched by the configured value.

Step 5

Review macro logs if the expected items were not archived.

Why This Matters

Automated inventory archiving helps:

  • Reduce manual inventory cleanup

  • Archive discontinued or matching SKU groups faster

  • Improve inventory list management

  • Reduce active inventory clutter

  • Support scheduled maintenance workflows

Best Practices

To get the most value from this macro, use precise SKU match values and review results carefully.

  • Use specific match text
    Use a precise SKU pattern so only the intended inventory items are matched.

  • Test with a small value first
    Run the macro with a narrow match value before using broader patterns.

  • Avoid common words or short values
    Short values may match many unrelated SKUs.

  • Review matching SKUs before running
    Search inventory manually for the intended suffixOrPrefix value before enabling the macro.

  • Run during low-activity periods
    Schedule the macro when users are not actively editing the same inventory items.

  • Monitor macro logs
    Check the macro logs after execution to confirm the macro completed successfully.

Troubleshooting

No items were archived

Confirm that inventory item numbers contain the configured suffixOrPrefix value.

Too many items were archived

The configured value may have been too broad. Use a more specific SKU pattern.

Macro finished but no visible change occurred

Check whether the query returned any stock item IDs and confirm that the items were not already archived.

Macro error occurred

Review the macro logs for the message written after Error occurred:.

Unexpected SKU matched

Remember that the macro uses a contains search. The configured value can match anywhere in the item number.

Macro is not running on schedule

Confirm that the macro configuration is enabled and that the schedule has been saved correctly.

Summary

The Inventory Archiving by SKU Match macro searches Linnworks inventory item numbers for the configured suffixOrPrefix value and archives all matching stock items.

It is useful for bulk inventory cleanup where SKUs share a common pattern, but the configured match value should be reviewed carefully before running because all matching inventory items are archived.