# Calc: JavaScript

Executing Javascripts client AND serverside

NOTE: **This feature is currently BETA, and features are subject to change.**

### Properties

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

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

Due to its nature this field has no special show or edit mode.

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

This field requires configuration before deployment.

<span class="mw-headline">\[INSERT IMAGE\]</span>

Edit the values using "Manual edit" feature

Required:

- Functional JavaScript (Configuration1)

#### <span class="mw-headline" id="bkmrk-help-for-syntax-1">Help for syntax</span>

The API currently supports the following language features

- All standard functions from JavaScript 
    - Librarys like Math
- Support for basic TS form functions 
    - getValue( variable )
    - setValue( variable, valueToAssign )
- **Unsupported** features include 
    - JQuery commands (clientside only)
    - JavaScript IO functions like **alert** and **input**
    - JavaScript DOM objects like **window** and **document**

#### <span class="mw-headline" id="bkmrk-important-notice-1">Important notice</span>

Some field values are represented differently server and client side, namely date and decimal values

<table id="bkmrk-field-client-side-ex"><tbody><tr><th>Field</th><th>Client side example</th><th>Server side format</th></tr><tr><td>Date</td><td>31/1/2014</td><td>2014-01-31</td></tr><tr><td>Decimal</td><td>1,23</td><td>1.234</td></tr></tbody></table>

Future versions will include these methods callable server and clientside

- getValueDate( fieldname )
- getValueDecimal( fieldname )
- getDateFromString( string )
- getDecimalFromString( string )

#### <span class="mw-headline" id="bkmrk-example-1">Example</span>

```javascript
if( getValue('NUMBER2') > 1000 )
    setValue('NUMBER1',  Math.round( 100 * Math.random() ) );
```

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

- FeltTypeID: 83
- SQL datatype: N/A
- Class name: FieldJavaScripting