Expression Editor

The Expression Editor is available everywhere that you use an expression. expressioneditor2

  1. Click to open the Expression Editor
  2. System variables that are always available to include in an expression
  3. Functions that are available to include in an expression
  4. Variables that are in scope, and available to include in an expression
  5. The expression
  6. Help on a selected Function. (To view help content, click on the relevant Function in the drop-down list)

Layout of the Expression Editor

layoutofexpressioneditor

The Expression Editor is composed of the following:

Expression area

Enter an expression or select relevant variables and functions from the available lists to build up an expression.

Variables and Functions

Variables folder

There are 2 categories of variables available to include in an expression:

  1. In-scope variables: Those variables that you have already created upstream within the same function for which you are creating an expression.
  2. Those variables you have already created as Settings.
  3. expression editor variables

System folder

The System folder includes system properties and functions.

  1. System properties
    • CurrentDateTime
    • NewLine
    • Null
  2. Functions


Function Help

functionhelp

To view help for a specific function, click on it where it is listed. The Help for the selected function is displayed in the help section.

Test

variablesandfunctionstest

To test an expression for correct structure and syntax:

  • Click on the Test tab

  • Click the Run Test button

  • The result of the test is displayed

    • A typical error message is: “Expression contains invalid syntax.”

Note:

When testing an expression, usually relevant input has to be provided by the user. If the expression references a Result from a function above, a value needs to be provided that will substitute the Result in the expression. The test will be executed with that value. If my expression is Integer1 + Integer2, then the user will be asked to provide two integers in the test tab for the test.

Working with Expressions

Linx uses C# expressions to evaluate values at run time.

Concept

Excel uses expressions in cells. These expressions evaluate to a single value visible in the cell. In a similar fashion Linx uses expressions when assigning values to properties. Linx expressions are evaluated at run time. Excel expressions use VBA syntax. Linx expressions use C# syntax. Linx expressions in property windows are preceded by a "=".

simpleexpression1

  1. = indicates that this is an expression
  2. Click here to open the Expression Editor
  3. Variables available to include in the expression
  4. Variable that is being configured


Definition

An Expression is a series of operands and 0 or more operators that evaluates to a single value.

Operand

Operands can be values, names or functions.

Values are numbers or strings e.g. 123, "abc". Strings are enclosed in double quotes.

Names refer to variables available in the scope of the expression e.g. amount + 1 will add 1 to a variable called amount and return the result. Properties of variables are referred to using the dot notation e.g. Person.Age + 1 will add 1 to Person.Age and return the result.

Functions are operations that can be performed on another operand e.g. Person.Birthdate.ToString("yyyy-MM-dd") will return Person.Birthdate as a string formatted to look like "2016-12-31". Functions can be strung together e.g. " 123,45 ".Trim().Replace(",",".") will return 123.45.

Operators

Operators include:

Operator

Description

+ Add, Concatenate
- Subtract
* Multiply
/ Divide
< Less than
<= Less than or equal
> Greater than
>= Greater than or equal
== Equal
!= Not Equal
&& And
|| Or

For a full list of C# operators go here. Linx does not support all the operators.

Things you can do

String concatenation

Strings are concatenated using + e.g. "ab" + "c" evaluates to "abc". Build a csv line with an expression like Person.Name + "," + Person.Surname + $.System.NewLine.

When strings are mixed with numbers the numbers are added until the first string is encountered. Thereafter operands are concatenated e.g.

"1" + 2 + 3 + 4 will evaluate to "1234".

1 + 2 + "3" + 4 will evaluate to "334".

String manipulation

Use functions like SubString, Trim, ToUpper, Split etc. to work with string variables e.g. TextFileRead1.FileContents.Replace("John","Peter") will replace all instances of "John" in the FileContents variable with "Peter".

String formatting

Use FormatWith to create a string from several different inputs. The above csv sample can be built as "{0},{1}{2}".FormatWith(Person.Name, Person.Surname, $.System.NewLine).

The numbers inside curly braces refers to the index of the parameter in the FormatWith part.

For larger string formatting jobs rather use a templating function like RazorTemplateTransform.

Calculations

e.g. AmountExVat * (1 + VatRate)

Date operations

Format a date: Person.Birthdate.ToString("yyyy-MM-dd")

Return the month: Person.Birthdate.Month

Boolean expressions

In properties where true or false are expected the expression must return a boolean value e.g.

Person.Name == "Mary" (name is Mary)

Person.Age < 10 && Amount > 500 (person is younger than 10 and amount is greater than 500)


Functions

Functions in an expression are operations that can be performed on data. Different functions apply to different types of data.

Go here for a list of functions.


Tutorial video

videos icon Expressions Tutorial Video