> 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/budowanie-aplikacji/proces-biznesowy/zadania-automatyczne/zadanie-skryptowe-bpms-scripttask.md).

# Zadanie skryptowe BPMS (scriptTask)

Domyślna opcja Camundy pozwalająca tworzyć proste, szybkie skrypty, bez konieczności tworzenia handlerów Java/ScriptCode.

Dostępne języki to np. Groovy/JavaScript.

## Dokumentacja <a href="#zadanieskryptowe-scripttask-camundy-dokumentacja" id="zadanieskryptowe-scripttask-camundy-dokumentacja"></a>

<https://docs.eximeebpms.org/manual/latest/reference/bpmn20/tasks/script-task/>

<https://docs.eximeebpms.org/manual/latest/user-guide/process-engine/scripting/>

## Podpinanie ScriptTask do procesu <a href="#zadanieskryptowe-scripttask-camundy-podpinaniescripttaskdoprocesu" id="zadanieskryptowe-scripttask-camundy-podpinaniescripttaskdoprocesu"></a>

Wybieramy **Task** i podtyp **ScriptTask**:

* Format: Język np. Groovy/JavaScript,
* Type: Inline Script,
* Script: skrypt, który chcemy wywołać .

<figure><img src="/files/cbDhUEjjYQDbZ2siLFAh" alt="" width="347"><figcaption><p><em><strong>Ilustracja 1.</strong> Przykład podpięcia ScriptTask w procesie</em></p></figcaption></figure>

## Popularne metody <a href="#zadanieskryptowe-scripttask-camundy-popularnemetody" id="zadanieskryptowe-scripttask-camundy-popularnemetody"></a>

```
execution.getVariable("variableName") - Pobiera zmienną procesu
execution.setVariable("variableName", value) - Ustawia zmienną procesu
execution.removeVariable("variableName") - Usuwa zmienną z procesu
execution.hasVariable("variableName") - Sprawdza czy istnieje zmienna w procesie 
execution.getProcessInstanceId() || execution.getId() - pobiera ID procesu
```

<details>

<summary>Ustawnie danych widocznych w Eximee dashboard</summary>

```
    dashboardsParams = [
        "[1]Imię i nazwisko"             : execution.getVariable("clientFullName"),
        "[3]Ogólny typ dyspozycji"       : execution.getVariable("globalCaseTypeName"),
        "[4]Grupa produktowa"            : execution.getVariable("caseGroupName"),
        "[5]Dyspozycja"                  : execution.getVariable("caseTypeName"),
        "[13]Ostatnia osoba procedująca:": execution.getVariable('executorFirstName') +
        " " +
        execution.getVariable('executorLastName') +
        " (" +
        execution.getVariable('executorId') +
        ")"
        ];
 
    if (execution.getVariable("corpFullName") != null) {
        dashboardsParams["[2]Firma"] = execution.getVariable("corpFullName");
        }
 
        dateFormat = "dd.MM.yyyy h:mm"
 
    if (execution.getVariable("startBusinessStatusDate") != null) {
        dashboardsParams["[8]Data rozpoczęcia procesu:"] = execution.getVariable("startBusinessStatusDate").format(dateFormat)
        }
    if (execution.getVariable("tour1BusinessStatusDate") != null) {
        dashboardsParams["[9]Data rozpoczęcia I tury:"] = execution.getVariable("tour1BusinessStatusDate").format(dateFormat)
        }
    if (execution.getVariable("tour2BusinessStatusDate") != null) {
        dashboardsParams["[10]Data rozpoczęcia II tury:"] = execution.getVariable("tour2BusinessStatusDate").format(dateFormat)
        }
    if (execution.getVariable("tour3BusinessStatusDate") != null) {
        dashboardsParams["[11]Data rozpoczęcia III tury:"] = execution.getVariable("tour3BusinessStatusDate").format(dateFormat)
        }
    if (execution.getVariable("endBusinessStatusDate") != null) {
        dashboardsParams["[12]Data zakończenia procesu:"] = execution.getVariable("endBusinessStatusDate").format(dateFormat)
        }
    if (execution.getVariable("sposobWysylki") == "false"){
        dashboardsParams["[14]Sposób wysyłki:"] = "e-mail"
        }
 
execution.setVariable("TASK_DASHBOARD", dashboardsParams);
execution.setVariable("PROCESS_DASHBOARD", dashboardsParams);
```

</details>

<details>

<summary>Obsługa JSONa w JS</summary>

```
const data = execution.getVariable("kgSymulatorData")
const cif = S(data).prop("cif").value()
const creditAmount = S(data).prop("creditAmount").value()
const phone =  S(data).prop("phone").value()
const email = S(data).prop("email").value()
 
 
execution.setVariable("cif", cif);
execution.setVariable("creditAmount", creditAmount);
execution.setVariable("phone", phone);
execution.setVariable("email", email);
```

</details>

<details>

<summary>Zamiana JSON w typie string na typ Object</summary>

```
// Wartość skpToControl -> [{"skp":"198500"},{"skp":"198700"}]
def raw = execution.getVariable("skpToControl")
def parsed = new groovy.json.JsonSlurper().parseText(raw)
 
def list = parsed.collect { item ->
    def m = [:]
    item.each { k, v -> m[k] = v }
    return m
}
 
execution.setVariable("skpObj", list)
```

</details>

Więcej informacji o JSON: [https://docs.camunda.org/manual/7.7/reference/spin/json/01-reading-json/](https://docs.camunda.org/manual/7.7/reference/spin/json/01-reading-json/?__hstc=218867270.701d355f32e667d247d52b3da539ef04.1729075947404.1729075947404.1729075947404.1&__hssc=218867270.1.1729075947404&__hsfp=456839464#reading-json-properties)


---

# 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 dynamically by asking a question.

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

```
GET https://docs.eximee.com/budowanie-aplikacji/proces-biznesowy/zadania-automatyczne/zadanie-skryptowe-bpms-scripttask.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
