The Linnworks Blog
SYNCHRONISING THE ECOMMERCE WORLD

BACK TO BLOG

How To: Scripting in Linnworks

Scripting in Linnworks

 

Linnworks allows you the ability to further customise how it works using scripting.

This is, in essence, programming using a smaller part of the C# programming language we write Linnworks in.

Scripts come in 2 flavours, Order Scripts and Macro Scripts:

Order Scripts

Run when an order is imported from the channel. Useful for merging, splitting, allocating Shipping methods based on destination, weight, value and other details of items within the orders.

Macro Scripts

Run as part of the Linnworks Sync Process. Can be used for unusual imports and exports, generating emails to suppliers or customers outside of the included Email automation.

Scripts allow you to automate specific areas of your business process in a very targeted and specific fashion. This means that you can have Linnworks perform some more of the repetitive manual tasks for you, freeing up your time, or that of your staff to work in other areas, and reducing the overhead of time as your business grows! This also means that you can focus the training and responsibilities of your staff on areas suited to people, and the tasks requiring repetitive changes to order information, for example, can be made transparent to the rest of the business.

While customers on Standard subscriptions or above can log a support ticket to request a quote for a script, some may have developers on staff, or have some experience of programming themselves. At that point they may be interested in trying to produce a script themselves. In this article we will provide some advice for those people wishing to get to grips with Scripting in Linnworks. As with most areas of interest in Linnworks, we have articles on Order Scripting and Macro Scripting. We also have sample scripts for reference on some frequently used tasks (Search for 'Sample' in the knowledge base search box at the top right hand corner of the Linnworks homepage.

Furthermore you can watch this video of scripting in Linnworks.

http://youtu.be/lIhSY7DAyjk

Below, with the assistance of one of our developers, John, we're going to show an example of a Linnworks script with some of the basic actions covered. If you check back to our Linnworks Blog next week, we'll be posting a follow up article covering some more areas of scripting in Linnworks.

This article, and the following article, can be reviewed by those interested in the scripting functionality, including developers whose services you may have retained. As such, the following section may be more technical than many would be comfortable with.

In the screenshot below, we have highlighted the editable areas of the initial script you will see in Linnworks' Order Automation. The darkened areas are 'framing' code that Linnworks will not allow you to edit:

 

An Illustration of the Linnworks Order Script Editor

Linnworks Scripting Editor

The Linnworks script editor provides the same syntax highlighting and Intellisense which you would normally find in Visual Studio. It makes it simple to discover which libraries and methods are available. The core modules for Linnworks are exposed under the linnworks.finaware.CommonData.* namespace.

Some modules of interest are:

CodeHelper - A collection of useful functions which help to make common tasks easier.

Inventory - Access to stock items and stock levels. There are methods available for most common stock item related tasks.

Locations - Commonly used to get location name from location ID or location ID from location name.

OrderData - Order-related functions are stored here. In the case of Order Automation scripts, an order object will be passed into the Initialize function by Linnworks.

Email - Used for adding e-mails to the e-mail outbox or for directly sending e-mails.

Suppliers - Commonly used to get supplier name from ID or ID from name.

Linnworks also exposes some .NET namespaces, including:

System

System.Collections.Generic System.Data

System.Data.SqlClient System.Xml

Common Macro script tasks include:

Stock level updates

Creation of new items as they are added to a supplier's inventory

eBay Feedback request e-mails

Common Order Automation script tasks include:

Assigning postal services to orders

Assigning orders to fulfillment centres based upon availability

Uploading of orders to suppliers (by web service, for example)

We also have a sample script and CSV file to illustrate some common tasks undertaken in Linnworks.

StockUpdate.cs - The program file, rename from 'Stockfile.cs.txt' to 'Stockfile.cs' after download.

Stockfile.csv - A sample import file .

Topics: Linnworks News, Linnworks 'How To'

Subscribe To Our Blog!

POPULAR POSTS