# Script function

Execution of javascript with value insertion into other fields

### Properties

- Type: [Basic](https://docs.tsnocode.com/books/field-type-reference/chapter/basic)
- Groupable: No
- Show in lists: No
- Searchable: No

## <span class="mw-headline" id="bkmrk-user-interface-1">User interface</span>

This field is not displayed as a normal field, nor is the value of it saved and available to codeunits/sql-statements.

Due to its nature this field has no special editing mode.

## <span class="mw-headline" id="bkmrk-configuration-1">Configuration</span>

<span class="mw-headline">This field requires configuration before deployment.</span>

[![image.png](https://docs.tsnocode.com/uploads/images/gallery/2025-07/scaled-1680-/8QenRyw4f5dNZ0l5-image.png)](https://docs.tsnocode.com/uploads/images/gallery/2025-07/8QenRyw4f5dNZ0l5-image.png)

### <span class="mw-headline">Input</span>

<span class="mw-headline">Is a list of fields, which values will be available as variables in the following function.  
If a name contains "!", it will be loaded as a decimal.  
So this configuration:</span>

```
FIELD1 FIELD2! !FIELD3
```

<span class="mw-headline">Results is this code:</span>

```javascript
let FIELD1 = getValue("FIELD1")
let FIELD2 = getDecimal("FIELD2")
let FIELD3 = getDecimal("FIELD3")
```

<span class="mw-headline">Plus all those fields will trigger a re-evaluation of this field, whenever they are updates/changed.</span>

### <span class="mw-headline">Code (Function)</span>

<span class="mw-headline">The actual javascript that modifies the data collected from the inputs.  
Is pasted into a function, so should only contain lines of code.  
Must have a return statement!  
</span><span class="mw-headline">Sample:</span>

```javascript
return FIELD2 * FIELD3;
```

### <span class="mw-headline">Output</span>

<span class="mw-headline">The field to set the value of, with the return value of the final function.  
The output of the function will also be the value of this field, but will not be saved, as this field is virtual and only works in the frontend.</span>

## <span class="mw-headline" id="bkmrk-developer-info-1">Developer info</span>

- FeltTypeID: 620
- SQL datatype: N/A
- Class name: FieldContentFunction