> For the complete documentation index, see [llms.txt](https://kb.logicerp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/writing-formulas-in-the-script-editor/script-editor.md).

# 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**.

```vb
'#@VBNET
Dim TempBonus As Double = 0
Dim TmpVarCol As Object

For Each TmpVarCol In Arr_ALLOW_DED
    If UCase(TmpVarCol.Name & "") = "BONUS" Then
        TempBonus = Val(TmpVarCol.Value & "")
    End If
Next
ACTUAL_SALARY = Round(ORG_NET_SALARY - TempBonus, 2)
```

### **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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/writing-formulas-in-the-script-editor/script-editor.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
