You are currently viewing documentation for Linnworks Desktop, if you are looking for documentation, click here.

Macro Scripting

Videos for this article


Linnworks macro engine allows you to inject your own automation behaviour into Linnworks by creating a Macro script that runs every time the system synchronizes. A script is essentially a set of commands written in .Net C# that gets executed during every synchronization.

Generic Macro scripting is used to run a set of automated tasks, unlike Order Scripting (see Scripting - Orders), which is executed against every open or processed order on the system, the generic script is executed once during the synchronization – which means it is ideal candidate for doing things in a batch.

Here are some examples of what Macro Script can be used for

  • Email Feedback request to a customer after certain number of days since posting an order
  • Email personalized marketing material to previous customers asynchronously.
  • Export and Import orders to and from external systems.
  • Interfacing with external systems for whatever purpose.
  • Raise and email/submit purchase orders to suppliers.
  • Implement System notifications, i.e. send yourself an email of low stock, stock you need to reorder, late deliveries
  • Implement your own automated import routines from CSV, XML or a webservices.
  • Plugin custom channel integration module
  • Generally – any sort of automatic task

Create new macro script

  • Settings > Macro
  • Click New
  • Specify the name for the script
  • Save the script

The script can be enabled/disabled

  • To enable/disable the script, click on Enabled
  • Gray = disabled, Green  = enabled

The script has execution order

  • To move up or down use up/down arrows 

Writing a macro

The syntax of the code is standard C# with most common namespaces attached in the compilation, so you have access to file system, networking components etc. But most importantly you have direct access to commondata library – which exposes most of the data queries and manipulations. In addition you have ActiveConnection parameter, this is supplied in the Initialize method as a parameter and you can use it to run data queries against your system. Since this documentation is not intended to describe every method, field and function in C# and linnworks data adapter, we can only give some pointers as to how to work with scripts. The scripting has full InteliSense – meaning that when you type the code, the method, function or a property of the object will have a comment, which describes what it does.

The code syntax is .Net C# (version 2 compile). The script has access to the following namespaces

  • System
  • System.Data
  • System.Xml
  • linnworks.finaware.CommonData

The code must be placed inside public void Initialize(..) method.



When writing a script it is sometimes necessary to output some debugging text to show value of certain variable. Initialize method provides a debug class variable.
To output a value in the debug window

debug.AddEntry("[my text]");

To output script progress

debug.Progress(50,"We are at 50%");

The script progress propagates to Linnworks Synchronization progress. When running long scripts it is a good idea to keep the user informed of the progress.

Videos and Files

Order scripting and macro programming in Linnworks - Webinar (1.5h)

The main purpose of the webinar will be to get all new customers familiar with the software by covering basic configuration steps