--- title: "Expression Editor - Lasernet FO Connector User Guide" slug: "expression-editor" description: "The Expression editor can be used to build expressions, from simple expressions such as hard-coded values to more complex expressions." updated: 2025-10-27T09:30:32Z published: 2025-10-27T09:30:32Z canonical: "kb.lasernetgroup.com/expression-editor" --- > ## Documentation Index > Fetch the complete documentation index at: https://kb.lasernetgroup.com/llms.txt > Use this file to discover all available pages before exploring further. # Expression Editor The Expression Editor can be used to build expressions. These can range from simple expressions, such as hard-coded values, to more complex expressions that integrate functions and use logic. Expressions return a value, and the type of value can vary depending on how the expression is being used. Some examples of different values an expression can return include a numerical result from a calculation, a string value from a table, a 0 or 1 for a condition, and many more. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-WA48CTSX.png) Expressions can be used in multiple places within the Lasernet FO Connector, including, but not limited to, the report Structure, Conditions, and individual fields with the toolbox icon. The following are some of the fields within the **Report settings** FastTabs that include the toolbox icon. Click this icon to open the Expression Editor. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-CKS3WX2Q.png) The Expression Editor is resizable. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-8VOMG5QW.png) ### Overview The Expression Editor interface consists of a **Syntax editor** section, an **AVAILABLE FUNCTIONS** section on the lower left-hand side with additional information, and testing functions available on the lower right-hand side. ### Syntax Editor The Syntax Editor is the place where the expression is written and automatically validated. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-MBNMVJOV.png) The Syntax Editor supports the following: - Enables fast typing while performing syntax analysis in the background. - Automatic parallel syntax analysis and colors on expression segments. - String values can be within single or double quotes. - Multi-line expressions - Switch–case - An autocomplete list when typing. - Automatic validation while typing. - Error position reporting with a callout indicating the exact place of the error. - Enums can be used as value sources. - The syntax editor area is resizable. - Comments ### Available Functions The **AVAILABLE FUNCTIONS** section has useful options that can be used to build the expression. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-E8CWMRF0.png) More information on the options under **AVAILABLE FUNCTIONS** is available on the left-hand side. ### Value The **Value** options under the **AVAILABLE FUNCTIONS** section are typically tables associated with the current report. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-ECW8VJZ1.png) Selecting a table from the **Value** menu will populate the **Select value** field on the right-hand side of the Expression Editor. The dropdown can be used to choose a field from the selected table. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-LE9F61UK.png) Selecting a field for a table in the **Select value** field will insert the table and field into the Syntax Editor. Additional information on the selected table and field can be found under **Select value**. In the following example, field **CustConfirmJour.ConfirmId** has a **Base Type: String** and a **Type name: ConfirmId**. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-D43393SM.png) The **Remove** button can be used to clear the selected object in the Syntax Editor. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-CKSIH6HV.png) Using **Clear** will clear any selection in the **Select value** field. Using the dropdown menu on **Select value** shows all the available tables for the report, as well as additional functions that can inserted into the expression such as **Aggregate**, **Calculated**, **Convert**, **Enums**, **Forms**, **Label**, **LanguageText**, **Parameter**, **ReportValue**, **subreport**, **Value**, and more. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-3GKR9XYV.png) **Value** represents a string value and can be used to insert free text into the expression. This may be useful if you want your expression to output a phrase. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-RA4T3A5F.png) #### Reserved The **Reserved** options are reserved values such as names of functions (**if** and **Switch**) or symbols (for example, ***/** or **()**). ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-3Z176SOI.png) When a **Reserved** function is selected, a description appears on the right-hand side. The **Insert** button can be used to insert the reserved function into the Syntax Editor. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-W3Y95OKR.png) Once the reserved function is inserted, each argument can be selected and modified by either using the **Select value** or typing directly into the Syntax Editor. The underline shows which argument is currently selected in the expression. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-WG5S46UZ.png) **Delete all** can be used to clear an entire expression with multiple arguments. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-40AYQL97.png) #### Operator The **Operator** options are operators that can be used to calculate values. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-INMTQMB5.png) In the following example, the **CustConfirmJour.SumTax** and **CustConfirmJour.ConfirmAmount** are added together using an operator. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-CQKXE1OG.png) #### Predefined Functions The **Predefined functions** provide the option to add functions (methods) from the UI of the existing application (AOT) without the need for customization. It is useful when manipulating functions related to date, for example, finding the first date in a quarter or the end date of a quarter, or a year, etc. Several methods already exist in the standard application. For example, the standard **Global** class contains numerous useful methods/functions. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-ZIVVGZSS.png) As previously mentioned, you can use the right-hand side to find more information on how to use each predefined function. Use **Insert** to insert the predefined function into the Syntax Editor. Use **Select value** or type directly into the Syntax Editor to modify the arguments of your predefined function. **Test with values** can be used to verify the expression using system-specific values. In the following example, the predefined function **wkOfYr** calculates the week of the year that a date falls in, according to the ISO 8601 specification. Field **CustConfirmJour.ConfirmDate** was used as the argument for this function. The **Value** dropdown in the **Test with values** section was used to select a confirmation date that exists in the system. Selecting **Calculate test result** shows the result of the **wkOfYr** function on a confirmation date of **2023-10-17** is **42**. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-AUTJ239W.png) #### Add System Function It is possible to add and reuse methods from standard Dynamics 365 for Finance and Operations. To this end, select and add methods from either the tables or from the classes by using the **Add system function** option. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-MED6F6VU.png) You can select the **Object type, Class name**, and **Method name,** and provide a brief description. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-OFWCSZ6D.png) Once you click **OK**, a new menu will be created under **AVAILABLE FUNCTIONS**, and the new function/method will be added under it. In this example, a **Global** menu was created because the **Global** Class name was used. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-HHNVXYFJ.png) The newly created method can now be used. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-MB7DZYXT.png) To delete any created method or function, select **Expression function** in the **General** tab of the **Lasernet parameters** page (**Lasernet** > **Setup** > **Parameters**). This location is used to avoid accidental deletion of a method or function by an end user. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-B5TG7PMY.png) ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-ENZDN0Z4.png) ## Expression Editor Features ### Expression Typing and Auto-Complete The auto-complete function will show up as soon as you start typing in the Expression Editor. It will automatically filter values based on the context of the expression and what has already been typed. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-9H1IL0JQ (2).png) Images on auto-complete lookup will indicate the types of available objects. | General | Description | | --- | --- | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-6FJHW5EU.png) | Value source | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-DTCQIM7H.png) | Enum | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-W3B19Z03.png) | Function/method | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-RCVLOMKK.png) | Table | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-SOSUSRSI.png) | Operator or reserved word, such as (IF, THEN, SWITCH) | | Fields | Description | | --- | --- | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-MYPCJ9WI.png) | Container field | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-SUVLZILZ.png) | Date field | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-0Y58MIRM.png) | Enum field | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-8VFFQ9DN.png) | Integer field | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-HLVN6WUX.png) | Real field | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-80NVQJ3I.png) | String field | If you start typing C, the editor will automatically show all available sources starting with “C”. **CustConfirmJour** and **CustConfirmTrans** are the tables that are available for the report, and, in this example, the **SalesConfirmReplacement** is used. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-9B25FYPV.png) If you select or type the table name and continue typing the field name, all available fields and methods will appear in an auto-complete list. ### Error Reporting Syntax analysis and error reporting are automatic. If there is an error in the expression, an automatic callout with a short error message will appear, and a longer version will appear in the status line below the editor. > [!NOTE] > Note > > The error position in the status line indicated with **<-!->**. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-ACQBLM5Z.png) ### Syntax Multi-line expressions are supported. Comments are also supported to enhance the documentation of certain expression parts. For example: ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-ONTKC3ER.png) #### Syntax Colors Syntax elements are color-coded: | Syntax Highlights | Description | | --- | --- | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-UW3W3L00.png) | Blue is reserved for operators and reserved words. | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-FZGC16P0.png) | Dark green is for complete value segments. | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-T0DDGC0W.png) | Dark red is for string constants or numeric constants. | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-YBN62GDZ.png) | Light green is for comments. | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-7D6STESN.png) | Bright red is for incomplete values. Complete expressions should not contain these. | | ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-UYICKUAK.png) | Regardless of color, underlined segment is **Active**. Value for such segment will also be editable in a separate value field located below: ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-NL76M475.png) | Be aware that syntax highlighting may be slow in environments with high network latency. Due to automatic validation and highlighting, a few round-trips to the server are required. You can monitor latency in your browser by navigating to **F12** > **Network**. An established VPN connection can also slow performance, as the latency can be higher than when running the software without a VPN. ### Enums The value source called Enums is supported. Enums will also appear in the auto-complete lookup, but only when the filter reduces the number of them below 20. This is done to avoid loading a massive amount of data, as the system contains many enums. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-5NLVNXPF.png) Enums support three types of values. For example, if **SalesTable.Sales** status is **Open order**: 1. (New) **SalesTable.SalesStatus** would return the numeric value of the enum, such as **1**. 2. **SalesTable.SalesStatus:NAME** would return a symbolic representation of the enum, such as **Backorder**. 3. **SalesTable.SalesStatus:LABEL** would return the enum label, such as **Open** **order**. If these are used in expressions, ensure that you compare the same type of value. Best practice is to use **:NAME**, as this will be consistent across all environments, even where numeric values may differ. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/download (1)(1).png) Auto-complete also works with enum values: ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-BAL0RKC8.png) ### Expression Testing Functionalities for testing expressions are supported. You can test expressions with different values that can be plugged into the expression and observe the output result. To test your expression, specify the test values, then click **Calculate test result**. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-PG1BTAUA.png) All test values are saved as **LastValues** in the user’s **Usage data** under **Class** > **LACExpressionParser** > **TestValues**. The **Calculate test result** checkmark is also saved in **Usage data** as **Form** > **LACExpressionEditor** > **CalculateTestResult**. Normally, test values can be reused across various expressions, as these are common for all of them. Only relevant values are shown by default, but you can show all test values saved for the user by clicking **Show all**. Select **Clean test values** to indicate how many test values are saved for a user. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-L0FEC393.png) If the calculation fails, you will get the following test error: ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-JIK9CQIC.png) In this case, the expression is technically valid; however, comparing an integer enum value with a string results in a runtime error during testing. ### **Examples - How to Write Expressions** #### Combine Text with Dynamics 365 Fields in Expressions Navigate to the report's **Structure** and follow these steps to combine text with Dynamics 365 fields in expressions: 1. Click the **New** button to create a new field. This must be done after selecting where you wish this new field to be placed in the XML (in this case, **SalesInvoiceHeaderFooterTmp**). ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-ONTDSJL7.png) 1. Give the new field a name. 2. In the **Expression** column, click the dropdown button and select **Expression**. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-II01DYSE.png) #### Layout Text "Invoice Id - Invoice#" with Actual Invoice Number in Dynamics 365 1. In the **Expression** column, click the dropdown button, select **Value**, and type in the text "Invoice Id". 2. Click out of the box: the value should move to the **Expression** box at the top. 3. Click the dropdown button. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-2SO96M2Q.png) To add a second value (**"-"**), follow the same procedure: 1. In the **Expression** column, click the dropdown button, select **Value**, and type in the text **"-".** 2. Click out of the box: the value should move to the **Expression** box at the top. 3. Click the dropdown button. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-AAQXER8Z.png) To add the Invoice number from Dynamics 365, follow these steps: 1. In the **Expression** column, click the **+** button, select **Table**, and then select **Field**. 2. Click **Insert**: the value should move to the **Expression** box at the top. 3. Click **OK**. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-9B2C1NJA.png) #### Show Only a Part of the Text in the String/If Field - **Hide Line Field if Line Field is the Same as a Header Field** This example is carried out on a Sales confirmation report, where the delivery date is at the line level and the header level. At the line level, only dates that differ from the header date must be displayed. Follow these steps: 1. Find the line field on the **Condition** column, and choose **Code**. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-YV3GUXWB.png) 1. Click the **Edit** button. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-KUL0SX8N.png) 1. In the **Expression definition** box, paste in the following expression: **If SalesTable.DeliveryDate=SalesConfirmDetailsTmp.DlvDate Then 0 Else 1**, and click **OK**. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-5CMH8WP9.png) Header: ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-422AZSM5.png) Before: ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-JL551BGJ.png) After - No line field when the line field is the same as the header field: ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-FJWLTPQO.png) - **Show Only a Limited Part of the Substring - Expression: If SalesTable.ShippingDateRequested=SalesLine.ShippingDateRequested Then 0 Else 1** The following example illustrates how to create a substring for a Purchase order (Purch-Id). The number sequence consists of six characters, and only three must be displayed on the report. Follow these steps: 1. Create a new element by clicking the dropdown button. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-BKF7G942.png) 1. Paste in the following expression: **SubString ( PurchPurchaseOrderHeader.PurchId , 1 , StrLength ( PurchPurchaseOrderHeader.PurchId ) - 3 )** ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-6SBY82SR.png) The result is that the newly created element is **000**. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-VCUSBPNG.png) - **Show One or Zero if "CFR,CIF,CIP,CPT,DAT,DAP,DDP" Contains DlvTerm_Terms.Code** In this example, the system must return **1** when **True** and **0** when **False**, if the delivery term contains **CFR,CIF,CIP,CPT,DAT,DAP**, and **DDP**. Expression: **"CFR,CIF,CIP,CPT,DAT,DAP,DDP" Contains DlvTerm_Terms.Code** This will return **1** if **True** and **0** if **False**, without the need for the **If Else** statement. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-GC3PQRBL.png) #### Replace a Word with Another Word Some companies use the Proforma invoice or Sales confirmation as the Export invoice. Therefore, they want the title "Export invoice" to replace the title. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-25W4BO3A.png) Paste or build the following expression: **strReplace ( SalesConfirmHeaderTmp.LACOriginalReport_DocumentTitle() , "Confirmation" , "Export Invoice" )** Result: ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-O8R69R74.png) #### Calculate: Diving In this example, the **LineAmount** divided by **Qty** can show the "unit price after discount". To do so, create a new element by clicking the **+** button and paste it into the following expression: **SalesConfirmDetailsTmp.LineAmount/SalesConfirmDetailsTmp.Qty**. ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-95EXE62N.png) Result: ![](https://cdn.document360.io/c831ef63-c6b3-48ee-b443-3e33644e4e2e/Images/Documentation/image-VYIK3CKU.png)