> For the complete documentation index, see [llms.txt](https://docs.eximee.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/scriptcode/skrypty-scriptservice/api-skryptow/podstawy-pracy-ze-skryptami/dane-wejsciowe-i-wyjsciowe.md).

# Input and output data

Object `context` (available as an input parameter in platform scripts) is the main tool for interacting with the current form state. It allows you to retrieve parameters from the input map, read and modify component state, and invoke other services and validators.

## Object methods `context` (Input)

Below is a list of methods available on the input object:

### Retrieving script parameters

* `List<String> getParameters(final String name)` – retrieves the list of values assigned to the given key from the input data map.
* `String getFirstParameter(final String name)` – retrieves the first element from the list for the given key. Returns `"null"` if there is no value.
* `String getFirstParameter(final String name, final String defaultIfEmpty)` – retrieves the first element from the list, and if it does not exist or is empty, returns the defined value `defaultIfEmpty`.
* `Map<String, List<String>> getInputParameters()` – returns the entire map of input data passed to the script.

### Interaction with form components

{% hint style="warning" %}
The availability and type of attributes that can be retrieved depend strictly on the component type. More information on the page [Component attributes](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/jezyk-wyrazen-definiowania-warunkow-warunki-z-getvalue/atrybuty-komponentow.md).
{% endhint %}

* `String isVisible(final String id)` – returns whether the component with the specified ID is visible.
* `String getValue(final String id)` – retrieves the current value of the component or session variable with the specified ID.
* `String getData(final String id, final String attribute)` – retrieves the value of a specific attribute for the component with the specified ID.
* `void setValue(final String componentId, final String value)` – sets the given value `value` in the component with the specified `componentId` (the rule for providing the ID is the same as for `getValue`).

{% hint style="info" %}
When invoking a script inside a composite component, in order to set the value of a component / session variable embedded in the same component, you should `componentId` prefix it with the **`@`**.

In turn, retrieving data from outside (e.g. from a parent form) should be done while preserving encapsulation principles – by defining **input parameters** of the composite component and mapping the appropriate values to them.
{% endhint %}

{% hint style="danger" %}
**NOTE!** An attempt to execute `setValue` on a component that listens to another component, or on a component that other components listen to, results in an exception being thrown.
{% endhint %}

### Calling external services

* `List<Map<String, String>> callService(String name, Map<String, List<String>> input)` – allows calling an external service (ServiceProxy).
* `ValidatorOutput validate(String name, Map<String, List<String>> input)` – allows calling a validator from the script.

## Returning results (Output)

The result of script execution (e.g. when populating components) should be returned as an array. The platform supports this in two ways:

1. **List of maps** – the output array of objects is parsed into a list of maps, and then processed in the standard way by the calling component.
2. **Single map** – the return value is wrapped as a single-item list and processed in the standard way.

```javascript
// Example of returning a list of maps
function callService(context) {
    return [{'output': 'result1'}, {'output': 'result2'}, {'output': 'result3'}];
}
```

## Usage examples

### Populating the Value Select (Combobox) component <a href="#skrypty-scriptservice-przykladowyskryptzasilajacykomponentpolewyboruwartoscizlisty-combobox-example" id="skrypty-scriptservice-przykladowyskryptzasilajacykomponentpolewyboruwartoscizlisty-combobox-example"></a>

The script populates **Value Select** from a list (Combobox) based on the passed 'locale' parameter.

Outputs **id**, **label**, and **description** should be mapped to the appropriate Combobox fields, respectively **id**, **text**, and **description**.

Combobox-populating script:

```javascript
function callService(context) {
    const locale = context.getFirstParameter('locale');
    if (locale === 'pl') {
        return [
            { 'id': 1, 'label': 'Value 1', 'description': 'Description 1', },
            { 'id': 2, 'label': 'Value 2', 'description': 'Description 2' }
        ];
    } else if (locale === 'en') {
        return [
            { 'id': 1, 'label': 'Label 1', 'description': 'Description 1', },
            { 'id': 2, 'label': 'Label 2', 'description': 'Description 2' }
        ];
    } else {
        return [
            { 'id': 1, 'label': 'Default translation value 1', 'description': 'Description 1', },
            { 'id': 2, 'label': 'Default translation value 2', 'description': 'Description 2' }
        ];
    }
}
```

### Retrieving file names from the Attachments (UploadFile) component

The script uses the **getData()**&#x6D;ethod, which retrieves the value of a specific attribute for the component with the specified id. For the **Attachments** component, the names of added files are specified by the **fileNames** attribute and come from the request as a string in JSON format (e.g. *\["name1.png", "name2.png"]*), therefore it is necessary to convert this string into an object using the **JSON.parse**.

{% hint style="warning" %}
**NOTE!** method **getData()** uses the component ID, so the script is not universal - for each request, the appropriate component ID must be provided **Attachments**:
{% endhint %}

```javascript
function callService(context) {
    const firstAttachmentFiles = JSON.parse(context.getData("@GesUploadFile1", "fileNames"));
    const secondAttachmentFiles = JSON.parse(context.getData("@GesUploadFile2", "fileNames"));
}
```

### Retrieving the value of the Value Select from list (Combobox) in a Repeatable Section (RepeatableSection) <a href="#skrypty-scriptservice-fragmentskryptupobierajacegowartoscipolawyboruwartoscizlisty-comboboxa-zsekcji" id="skrypty-scriptservice-fragmentskryptupobierajacegowartoscipolawyboruwartoscizlisty-comboboxa-zsekcji"></a>

The script uses the **getData()**&#x77;hich retrieves the value of a specific attribute for the component with the specified id. For the **Value Select** the values (labels) of the given keys are specified by the **label.**

```javascript
for (let i=0; i<10; i++)  {
        let id = "GesRepeatableSection1.row" + i + ".GesCombobox1";
        let comboboxLabel = context.getData(id, "label");
}
```


---

# 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://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/scriptcode/skrypty-scriptservice/api-skryptow/podstawy-pracy-ze-skryptami/dane-wejsciowe-i-wyjsciowe.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.
