In this article we will share some of the most used expressions. If you have one - which is not on the list - please reach out and so we can add it.


TABLE OF CONTENTS


How to combine text with D365 fields in ExpressionsThis example is in D365 LAC Report structure

In the report structure click on New field where you would this field placed in the XML - e.g. LNHeaderFields
Give it a name 
Then under expression click on the 1) +
Select 2) Expression
Then click on 1) +

Example layout Text  "Invoice Id - Invoice#" with actual invoice number in D365


In the expression click on the 1) + the select  2) Value and 3) type in the text - Invoice Id 
4) Click out of the box and the value should move to the expression box on top. 
5) click on +

Start next value -
The same procedure as above
Next Value "-"
In the expression I click on the  1) + the select  2) Value and 3) type in the text  -
4) Click out of the box and the value should move to the expression box on top. 
5) click on +
Next is the actual invoice number from D365
In the expression click on the  1) the select  2) Table 3) Select field from Table
4) Click on Insert and the value should move to the expression box on top. 
click on OK
The XML that is generated looks like below:-



How to Show only some text in the string/If field


1. Hide line field - if line field is the same as header field

Example on sales confirmation; we have delivery date on line level and on header level.

On line level - we only want to show those dates which are different form the header date.


A. Find line field.

B. On condition Column - Choose code

C. Choose Expression



D. Paste in the following Expression: If SalesTable.DeliveryDate=SalesConfirmDetailsTmp.DlvDate Then 0 Else 1

E. Click OK

Or build it from Scratch


Header:

Result:

Before

Now No line field - when line field is the same as header field


Other Examples

(If SalesTable.ShippingDateRequested=SalesLine.ShippingDateRequested Then 0 Else 1)


2. Show only a bit of the substring

The following example illustrates how to make a substring of the Purchase-order (Purch-Id). The number sequence is 6 characters and we only want to show 3 on the report.


A. Create new Element

B. Click on +

C. Choose Expressions

D. Paste in the following expression: SubString ( PurchPurchaseOrderHeader.PurchId , 1 , StrLength ( PurchPurchaseOrderHeader.PurchId ) - 3 ) 

Result:

The purchase Order string is 001568 and the newly created element is 001


How to replace some text/thing in the string


1. Replace a word with another word

Example, Some companies uses the Proforma invoice or sales confirmation as Export Invoice - therefor they want the title "Export invoice" to replace the title.


Paste or build expression:


strReplace ( SalesConfirmHeaderTmp.LACOriginalReport_DocumentTitle() , "Confirmation" , "Export Invoice" ) 

Result:



Calculate multiply, subtraction, dividing


Dividing

Example - LineAmount divided by qty can show the "unit price after discount"

SalesConfirmDetailsTmp.LineAmount/SalesConfirmDetailsTmp.Qty

A. Create a new element


B. Paste in the following Expression:

SalesConfirmDetailsTmp.LineAmount/SalesConfirmDetailsTmp.Qty

or build it using the "Select value"

Result:


Create expression with multiple conditions

See separate article

https://formpipelasernet.freshdesk.com/en/support/solutions/articles/24000047428-create-expressions-with-multiple-if-conditions