# Script editor

## Script view <a href="#edytorskryptow-widokskryptuedycja" id="edytorskryptow-widokskryptuedycja"></a>

In the main script view, the selected script version is visible. The side panel contains buttons that allow you to slide out the script parameters, unit tests, and logs panels.

The script run button is located in the tab **Parameters**.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2F0TmsJe1PUFNwZGF50Zeh%2Fobraz.png?alt=media&#x26;token=e69a3cb1-113a-4bf2-8614-f3744e20ee25" alt=""><figcaption><p><em><strong>Figure 1.</strong> Script view with the "Parameters" panel slid out</em></p></figcaption></figure>

## Editing a script <a href="#edytorskryptow-edycjaskryptu" id="edytorskryptow-edycjaskryptu"></a>

Working on the script is possible thanks to the Monaco editor (the editor supports JavaScript).

Initially, it operates in **read-only**mode. To begin, click the **Edit script** button located at the end of the navigation bar.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FpDsYRgQPl4rH3dHk8U3r%2Fobraz.png?alt=media&#x26;token=8cc4b5a5-030f-483b-9eb5-bdcd52295c0f" alt=""><figcaption><p><em><strong>Figure 2.</strong> Script card</em></p></figcaption></figure>

The instruction "how to write a service script" can be found in [Scripts (scriptService)](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/scriptcode/skrypty-scriptservice) and [ScriptCode best practices](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/scriptcode/dobre-praktyki-scriptcode).

## Variables in ScriptCode within block scope <a href="#edytorskryptow-zmiennewscriptcodewzakresiebloku" id="edytorskryptow-zmiennewscriptcodewzakresiebloku"></a>

The Eximee platform requires that variables in ScriptCode be declared within block scope.

Failure to declare a variable will cause a script error.

## Parameters <a href="#edytorskryptow-parametryparametry" id="edytorskryptow-parametryparametry"></a>

Modifying parameters also takes place in Monaco (the editor supports JSON notation).

When entering a non-empty script for the first time, the parameters will be automatically deduced (if possible) from the script content itself.

Below the editor there is a button that allows you to run the script with parameters provided in the section **Test data.**

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FZGhTCgC3aErwubzZHQep%2Fimage.png?alt=media&#x26;token=7bd8a94c-556f-42c3-b412-bef8936ff85f" alt=""><figcaption><p><em><strong>Figure 3.</strong> Parameters tab</em></p></figcaption></figure>

Parameters filled in the section **Test data** are not part of the script itself and will not be saved in that version of it!

## Editing inputs/outputs <a href="#edytorskryptow-edycjawejsc-wyjscio" id="edytorskryptow-edycjawejsc-wyjscio"></a>

Here we can add or remove the service script's inputs/outputs.

Adding or removing an input will also update the run parameters, so after removing a parameter we will lose its possible mapping at the attachment point.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FG7THbWAG1fnmjd43jtgB%2Fimage.png?alt=media&#x26;token=d832a322-70d0-47c2-a7e7-fa20ca209253" alt=""><figcaption><p><em><strong>Figure 4.</strong> Input/output edit fields</em></p></figcaption></figure>

## Script result <a href="#edytorskryptow-wynikskryptuwynik" id="edytorskryptow-wynikskryptuwynik"></a>

An additional window appears at the bottom of the screen. There you will find all information about the script that was run:

1. Script execution time given in ms.
2. Script execution logs in the form:

   | `[OPERATION_TIME] [OPERATION_TYPE]: Operation text` |
   | --------------------------------------------------- |

   For example:

   | `[14:31:22,976] [GET_DATA]: Called getData("GesCustomComponent1","data") and resulted with data z cc` |
   | ----------------------------------------------------------------------------------------------------- |
3. The result of calling the script (in the log panel), that is, all values defined as output during service script creation, in the form KEY : VALUE.<br>

   <figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2Fv1eNGJCtvc7hNEAZDzLM%2Fimage.png?alt=media&#x26;token=be3b5bfa-5dcf-444b-9e5d-8de1e2fb069c" alt=""><figcaption><p><em><strong>Figure 5.</strong> Script result card</em></p></figcaption></figure>

## Monaco editor <a href="#edytorskryptow-edytormonacomonaco" id="edytorskryptow-edytormonacomonaco"></a>

The editor used in the project is a full-fledged editor, and thus offers us a set of shortcuts to assist with writing. List of the most commonly used keyboard shortcuts:

* **Ctrl + Shift + I** - code formatting. After writing any fragment, it is always worth formatting it, as this increases readability and makes work easier.
* **Ctrl + Shift + O** - jump to variable/function. This is search on steroids. When scripts grow to a size where they no longer fit on one page, it is worth using such shortcuts to move around the code faster.
* **Ctrl + Shift + K** - delete the entire line.
* **Ctrl + F2** - find and replace a specific symbol (function name, variable).
* **Ctrl + G** - jump to line.
* **Ctrl + Shift + Alt + Up/Down Arrow** - clone the cursor above/below.
* **F1** - list of all available shortcuts and editor options.

## Tests <a href="#edytorskryptow-testy" id="edytorskryptow-testy"></a>

The editor allows defining [test scenarios](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/scriptcode/testy-jednostkowe-skryptow).

### Errors during test execution

If the script contains errors, during test execution such an error will be logged in the console below the editor. The message will include the cause and the code location where the error occurred.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FZFoY32oGd8Olk5TxH1BN%2Fobraz.png?alt=media&#x26;token=1a4bb1b1-77e4-4370-af18-ca5585c48107" alt=""><figcaption><p><em><strong>Figure 6.</strong> Test call error</em></p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/scriptcode/skrypty-scriptservice/edytor-skryptow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
