LEN() Function
YouTube: How to Use the Len Function in Report Custom Columns?
How to Use the Len Function in Report Custom Columns?
In this tutorial, we will learn how to create expressions using the LEN
function, which calculates the number of characters (length) in a given field such as Item Code
. You’ll apply this function both in the grid view and within a report layout.
Accessing the Expression Designer:
Open Sale Voucher or any document.
Navigate to the "Setup Column Attributes".
Here, you'll see a list of available columns that can be used to build expressions.
Click on "Add/Edit Expression Columns" where you can write your expression using predefined functions.

Writing Your First Expression
Every expression must start with the script header: '#@LSCRIPT

Click the (+) Plus icon to create a new expression.
Fill in the required fields:
Expression Name – A unique name for your expression.
Expression Type – Choose either Text or Numeric depending on the expected output.

Define the LEN Function Expression
Double-click the newly created expression to insert it into the script editor.
Enter the function using the following syntax:
Expression Name = LEN(ITEM_CODE)

Click Save to apply the expression.
Scroll down and check the box next to your expression to display it in the data grid.

Save and proceed to check the effect.
The grid will now display a new column showing the length of each Item Code.

Applying the Expression in a Report
Navigate to the Reporting section.
Open the Sales Register Detailed Report or any "Report".
Go to Setup Column Attributes as you did earlier.

Before adding the expression to the report, go to Other Settings.
Ensure the Script Editor is set to VBScript.

Click Save.
Note: VBScript is the default for new configurations but always verify this setting.
Adding and Using the Expression in the Report
Return to "Setup Column Attribute" window.
Click "Add/Edit Expression Columns".
Every expression must start with the script header '#@LSCRIPT

Click the (+) Plus icon to create a new expression.
Fill in the required fields:
Expression Name – A unique name for your expression.
Expression Type – Choose either Text or Numeric depending on the expected output.

Double-click the expression to insert it into the script editor.
Define the expression using:
Expression Name = LEN("ITEM_CODE")
This function converts the item name to uppercase letters.
Click Save.
Scroll down and check the box to enable the expression column in the report.

Save and proceed to check the effect.
Refresh the report to view the final result.
The report will now display a column showing the length of each Item Code as per the defined expression.

Last updated