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






Expressions

Overview

Expressions in Linnworks is a way of outputting data from the system based on a mathematical or functional expressions. This functionality applies to printing functions (printing invoices, labels), generating emails, running macro scripts and data export/import automation.

For example if you wanted to create a new field on an invoice which will contain some calculated value you can use Output Formula Value in the text field in the Template Designer and code the expression to output the desired result.

 

Operators

 

Boolean Not

not[a]

Performs a boolean Not operator on the parameter a. For example, Not[true] = false.

 

Evaluate

eval[r]  - where r is any valid Rule Basic string rule

Evaluates a Rule Basic string. I think this is an interesting operand function. In my Rules Engine, I may have rules that return a Rules Basic string. Then the result could be evaluated with this operand

function. That is, have rules that create other rules. Example: eval[concat["a:=5;", "b:=6;", "a+b"]]

 

If-else-end

iif[c, a, b] - where c is the condition and must evaluate to a Boolean. The value a is returned if c is true, otherwise, the value b is returned.

Performs an if-else-end

 

Is all digits

IsAllDigits[a]

Returns true/false indicating if the parameter is all digits. For example, IsAllDigits["1234"] = true

 

Is Null or Empty

IsNullOrEmpty[a]

Indicates is the parameter is null or empty.

 

Is True or Null

isTrueorNull[a]

Indicates if the parameter has the value true or is null;

 

Is False or Null

IsFalseOrNull[a]

Indicates if the parameter has the value false or is null

 

 

Arithmetic

Absolute Value

abs[p1] - where p1 can be converted to a double.

Calculates the absolute value of a numeric parameter.

 

Average

avg[p1, ..., pn] - where p1,...,pn can be converted to doubles

Calculates the average of a list of numbers. The list items must be able to convert to doubles.

 

Between

between[var, val1, val2] - where var, val1, and val2 are integers. if var >= val1 and var <= val2 then the function returns "true", otherwise, the function return "false".

Indicates if a value is between the other values. Please note that the comparison is inclusive.

 

Maximum

NumericMax[p1, ..., pn]

Finds the maximum numeric value in a list

 

Median

mid[p1, ..., pn] - where p1, ..., pn are numeric values

Calculates the median for a list of numbers

 

Minimum

NumericMin[p1, ..., pn]

Finds the numeric minimum value in a list

 

N2

N2[a]

Returns numeric value, 2 decimal places. For example N2[100/3] returns 33.33

 

Round

round[n, d] - where n is the numeric value to be rounded, and d is the number of decimal places.

Rounds a numeric value to the number of decimal places

 

Sin Wave

sin[a]

Calculates the sin of a number

 

Square Root

sqrt[a] - where a is a numeric parameter

Calculates the square root of a number.

 

 

String

Concatenation

concat[p1, ..., pn]

This operand function concatenates the parameters together to make a string.

 

Contains

contains[p1, p2, ...., pn] If p1 is in the list p2, ..., pn, this function returns "true" otherwise, this function returns "false".

Indicates if the item is contained in the list.

 

Double Quote

quote[]

Returns a double quote

 

Index Of

indexof[a, b1, ..., bn] - If the list b1, ..., bn contains the value a, the index of the value is returned, otherwise, -1 is returned. Please note that this is zero based indexing

Returns the index of a list item.

 

Join

join[a, b1, ..., bn] - where a is the delimiter and b1, ..., bn are the items to be joined.

Joins a list of items together using a delimiter.

 

Left

left[s, n] - where s is the string and n is the number of characters

Returns the left number of characters from a string parameter.

Example for Template Designer:

EVAL{BEGIN}
a:=IIF[len[[{ItemTitle}]] < 10, len[[{ItemTitle}]], 10 ]; 
left[[{ItemTitle}],a]
{END}

Left Pad

lpad[a, b, n] - where a and b are string values and n is numeric. The parameter p will be appended to the left of parameter a, n times.

Pads a string on the left with new values

Left Trim

ltrim[a]

Trims the spaces from the left of a string

Length

len[a] - where a is a string variable

Returns the length of a string

 

Lower Case

LCase[a]

Converts a string to lower case

 

Maximum

StringMax[p1, ..., pn]

Finds the maximum string in the list

 

Minimum

StringMin[p1, ..., pn]

Finds the minimum string in the list

 

Proper Case

pcase[a] - where a is a string

Converts a string to Proper Case. For example, the proper case of "buFFalo" "Buffalo"

 

Remove

remove[a, b] - where a and b are string

Removes the specified characters from the string

 

Replace

Replace[a, b, c] - where a is the search string, b is the value being replaced, and c is the value that is being inserted

Example For Template Designer
EVAL{BEGIN}Replace[[{ExternalReference}], "MAGENTO",""]{END}

Replaces one string with another string

 

Right

right[s, n] - where s is the string and n is the number of characters.

Returns the right number of characters from a string parameter

 

Right Pad

rpad[a, b, n] - where a and b are string values and n is numeric. The parameter b will be appended to the right of parameter a, n times.

Pads a string on the right with new values

 

Right Trim

rtrim[a]

Trims the spaces from the right of a string

 

Search String

SearchString[a, n, b] - where a is the string that is being searched, b is the string that is being sought, and n is the start position in a

Searches for a string within another string at a specified starting position

 

Sub String

SubString[s, a, b] - where s is the string, a is the starting point, and b is the number of characters extracted.

Extracts a substring from a string

 

Trim

trim[a]

Trims the spaces from the entire string. Please note that it does not remove spaces from the text itself, it only removes spaces from the start and the end of the string. In order to remove spaces from the text, please consider using replace[]

 

Upper Case

ucase[a]

Converts a string to upper case

 

 

 

Date and Time

 

Date Add

dateadd[date, "type", amount] - where date is a valid date, and type is "y", "m", "d" or "b" (representing year, month, day, or business days) and amount is an integer

Adds an amount to a date. Please note that the amount may be negative.

 

Day

day[d1] - where d1 is a date value

Returns the day of a date

 

Day Of Week

dayofweek[a]

Returns a day string. For example dayofweek[today[]] returns Wednesday.  

Note: dayofweek[now[]] will not work. Use dayofweek[nowf[]] instead.

 

Hour

Hour[a]

Returns numeric value. For example hour[nowf[] returns 12.

 

Maximum

datemax[d1, ..., dn] - where d1, ..., dn are dates

Returns the maximum date in the list

 

Minimum

datemin[d1, ..., dn] - where d1, ..., dn are dates.

Returns the minimum date in the list.

 

Month

month[d1] - where d1 is a date value

Returns the month of a date

 

New Date

date[m, d, y] - where m is an integer and is the month, d is an integer and is the day, and y is an integer and is the year

Create a new date data type

 

Now

now[] This operand function takes no parameters

Returns the current date

 

Now Formatted

Nowf[] Does not take any parameters.

Returns current time. For example NowF[] returns 2013-06-12 12:42:22

 

Now Format Date

nowfd[a]

Returns current time. For example:

Nowfd[""] returns 21/06/2013 12:42:22 (default format)

nowfd["ddd, dd MMM yyyy HH:mm:ss zzzz"] returns Fri, 21 Jun 2013 16:55:50 +01:00 (RFC 2822 format)

nowfd["dddd, dd MMM yyyy HH:mm:ss zzzz"] returns Friday, 21 Jun 2013 16:55:50 +01:00

For more info please visit: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

 

ParseDateTime

ParseDateTime[date, inputformat , outputformat]

Returns a given the date in the outputformat specified. 

ParseDateTime["2013-08-18","yyyy-MM-dd","MMM dd yyyy"]  returns Aug 18 2013

ParseDateTime["8/18/2013","M/d/yyyy","d/M/yyyy HH:mm:ss"]  returns 18/8/2013 00:00:00

The inputformat needs to match the date/time format on your machine. To retrieve the current format of your dates, e.g. the dReceievedDate, use EVAL{BEGIN}[{dReceievedDate}]{END}

Example: ParseDateTime[[{dReceievedDate}], "dd/MM/yyyy HH:mm:ss", "dd MM yyyy"] returns 18 08 2013

Date Format Descriptions

 

Today

Today[] Does not take any parameters.

Returns today's date. For example Today[] returns 2013-06-12

 

Year

year[d1] - where d1 is a date

Returns the year of a date