Skip to main content

How do I Use Expressions? - Knowledgebase / Lasernet FO Connector / Lasernet FO Connector FAQs - Formpipe Support Portal

How do I Use Expressions?

Authors list

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.

How to combine text with D365 fields in Expressions

This example is in D365 LAC Report structure. Follow these steps to combine text with D365 fields in expressions:

  1. In the report structure click the New field where you would want this field placed in the XML - e.g. LNHeaderFields. 

  2. Give it a name.

  1. Then in the Expression column, click the + button and select Expression.

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

  1. In the expression, click  the button and then select  Value and type in the text - Invoice Id

  2. Click out of the box and the value should move to the expression box at the top.

  3. Click the button.


Start next value -

The same procedure as above

Next Value "-"

  1. In the expression, click +, select Value and type in the text.

  2. Click out of the box and the value will move to the expression box at the top.

  3. Click  +.


Invoice number

Next is the invoice number from D365.

  1. In the expression click on the + button, select Table and then select field from Table.

  1. Click Insert and the value should move to the expression box at the top.

  1. Click  OK.


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


Hide line field - if line field is the same as a header field

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

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

Follow these steps:

  1. Find the line field and on the Condition column, choose Code.

  1. Click the Edit button and choose Expression.

  1. In the Expression definition box, paste in the following Expression: If SalesTable.DeliveryDate=SalesConfirmDetailsTmp.DlvDate Then 0 Else 1 and click OK.


Or you can build it by using the If condition and then click Insert:

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)

Show only a limited part of the substring

The following example illustrates how to make a substring of the Purchase-order (Purch-Id). The number sequence is six characters and we only want to show three on the report. Follow these steps:

  1. Create a new Element and click the + button.

  1. 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.


Show one or zero if the field contains the following value

You want to return one when true and zero when false if your delivery term contains "CFR,CIF,CIP,CPT,DAT,DAP,DDP"


Expression: "CFR,CIF,CIP,CPT,DAT,DAP,DDP" Contains DlvTerm_Terms.Code


This will return one if true and zero if false without the need for the If Else statement.


How to replace some text/thing in the string


Replace a word with another word

Some companies use the Proforma invoice or sales confirmation as Export Invoice - therefore they want the title "Export invoice" to replace the title.

 Paste or build  the 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

Follow these steps:

  1. Create a new Element and paste in the following Expression:

SalesConfirmDetailsTmp.LineAmount/SalesConfirmDetailsTmp.Qty

or build it using the "Select value".


Result:

Helpful Unhelpful

1 of 1 people found this page helpful

Add a comment

Please log in or register to submit a comment.

Need a password reminder?