Script Editor
The Script Editor is the window where you write a formula - a few lines that work out a value from the other values on the screen. It opens from screens that let you define your own calculation, for example the EXPRESSION VALUE column of Payroll Setups\Setup Expressions for Allowance/Deduction Calculation and the Add Formula button of Accounts\Configurations\Setup Journal Voucher Templates.
The same editor is used on the desktop and on the web.
Parts of the window
Field List - every value of the screen you can use in the formula, with its current value. Type in the search box above the list to find a field by the first letters of its name.
Script Results - after you press Script Watch, the values after the formula ran. For a VB.NET formula every field is listed.
Script - where you write the formula.
Complete Script - the formula as it will run, with everything the screen adds around it. You only read it here; write in Script.
Language - the language the formula is written in: VB.NET (#@VBNET), VBScript, PowerShell (#@POWERSHELL) or LScript (#@LSCRIPT). A new formula starts in VB.NET; an older formula opens in the language it was written in.
Use a field in the formula
Double-click a field in the Field List, or select it and press Enter in the search box. Its name is put into the script where the cursor is.
On the desktop, typing in the script also offers a list of field names to pick from.
A field's name in a formula is written without spaces or symbols - each one becomes _. For example GROSS SALARY is written GROSS_SALARY. Double-clicking always puts in the right name.
Variable column groups
Some reports add a group of columns by themselves, for example one column for each allowance and deduction in the Payroll Summary Report. Such a group shows in the Field List under its own name, in red.
In a formula the group is written Arr_ followed by the group name, with spaces and symbols written as _ - for example the group ALLOW/DED is written Arr_ALLOW_DED.
Each column of the group has a Name (the column's caption) and a Value. Go through the group with For Each and pick the columns you need by their Name.
A Value holds the column's figure as text, and a column with 0 may be blank. Read it as a number with Val, for example Val(TmpVarCol.Value & "") - a blank value then counts as 0.
Test the formula - Script Watch
Click a field in the Field List. Its name and value appear above the list; type a test value in the box next to the name and press Enter. Do this for the fields your formula reads.
Open Script Results and press Script Watch. The formula runs on these values and the list shows the results.
If the formula has a mistake, a message shows it. For a VB.NET formula you are offered Check & Fix, which lists every problem by its line. See Check & Fix.
Save or close
Press Save (Alt+S on the desktop). The formula runs once first; if it has a mistake it is not saved. Then confirm Are you sure you want to save script.
Press Close (Alt+C on the desktop, or the window's X) to leave without saving. After Are you sure you want to exit, the formula goes back to what it was when you opened the editor - including any conversion or fix you applied.
Changing the Language does not translate the formula. For a formula longer than 20 characters you are asked Changing the language does not translate your script. Continue? - No keeps the language as it was. To turn a VBScript or PowerShell formula into VB.NET, use Convert to VB.NET instead.
If a message says VB.NET scripts cannot be used on this computer, ask your Logic ERP support team.
Buttons for VB.NET
Convert to VB.NET - available when the language is VBScript or PowerShell. See Convert to VB.NET.
Check & Fix - available when the language is VB.NET. See Check & Fix.
On the web
On a wide screen the editor opens full screen. Normal size makes it a smaller window, Full screen makes it full again.
Hide fields gives the whole width to the script; Show fields brings the field list back.
The browser remembers both choices.
On a phone, a tablet or a narrow browser window the editor is always full screen; use Fields, Script and Results at the top to switch between the parts.