# Actions

## Actions section <a href="#akcje-sekcjaakcje" id="akcje-sekcjaakcje"></a>

A section **Actions** allows adding actions to the request for selected components that trigger events.

To define an action on the request, first add in the form the component for which you want to define the action (e.g. [Trigger](https://github.com/Consdata/eximee-docs/blob/main/budowanie-aplikacji/interfejs-uzytkownika/formularze/biblioteka-komponentow-bazowych/trigger.md)) and the component to which the action applies (e.g. [Popup](https://github.com/Consdata/eximee-docs/blob/main/budowanie-aplikacji/interfejs-uzytkownika/formularze/biblioteka-komponentow-bazowych/popup.md)).

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FoKpWsBzXE4egPxT2dIR7%2Fimage.png?alt=media&#x26;token=ce70d96b-e365-4c64-99a9-ae238872f415" alt=""><figcaption><p><em><strong>Figure 1.</strong> Section with defined actions</em></p></figcaption></figure>

## Adding an action <a href="#akcje-dodanieakcji" id="akcje-dodanieakcji"></a>

After clicking the **Add action** at the top of the section above the remaining actions (if there were any already on the request), an empty row is added, in which we first choose the action source in the field **Select action source**. The list will include only those request components for which an action can be defined.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FVIqtOlkqGYERiNzuocFQ%2Fimage.png?alt=media&#x26;token=c0f854f2-8a52-4093-9f4d-804b882f3555" alt=""><figcaption><p><em><strong>Figure 2.</strong> Row for defining a new action</em><br></p></figcaption></figure>

***Figure 2.** Row for defining a new action*<br>

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FKYozZ9SWdFW4g18NwWw6%2Fimage.png?alt=media&#x26;token=983d6f37-d761-4fe0-8fd4-51fd2e320a55" alt=""><figcaption><p><em><strong>Figure 3.</strong> Row of a sample SHOW_POPUP action after clicking the checkbox</em></p></figcaption></figure>

## Defining an event for the Next button <a href="#akcje-definiowaniezdarzeniadlaprzyciskudalej" id="akcje-definiowaniezdarzeniadlaprzyciskudalej"></a>

When defining an action for clicking the Next button, remember to also provide an action that will be executed when the condition specified for the action is not met, because otherwise the user would not be able to move to the next page if the event condition is not satisfied. It is enough to add an action with the opposite condition for the FORWARD\_PAGE action.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FqmLVFLd4I66Yb8DTCDIB%2Fimage.png?alt=media&#x26;token=cdcaf690-a374-42a2-8e9d-85f330012c7b" alt=""><figcaption><p><em><strong>Figure 4.</strong> Example of an action opening a popup for the clicked Next button on Page1</em></p></figcaption></figure>

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FY3P7z4Ue3YGVQwPWEDrW%2Fimage.png?alt=media&#x26;token=96f8efff-340f-40d4-a064-9031e255dab8" alt=""><figcaption><p><em><strong>Figure 5.</strong> Example of an action for the opposite condition allowing you to proceed normally from Page1</em></p></figcaption></figure>

{% hint style="info" %}
Demo request: demoPopup
{% endhint %}

## Defining actions for the Statements component <a href="#akcje-definiowanieakcjidlakomponentuoswiadczenia" id="akcje-definiowanieakcjidlakomponentuoswiadczenia"></a>

For [Statements - Statements](https://github.com/Consdata/eximee-docs/blob/main/budowanie-aplikacji/interfejs-uzytkownika/formularze/biblioteka-komponentow-bazowych/oswiadczenia-statements/README.md) in a specific statement you need in **actionBindings** add an event (Event) equal to **EDIT**. A statement that has such an event defined will display a special data editing option, and clicking it will show a popup.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FSznVQFNfun8wb2khGvz0%2Fimage.png?alt=media&#x26;token=77986c2b-0b18-4ed9-bde5-52c5b37be4ad" alt=""><figcaption><p><em><strong>Figure 6.</strong> Example of a statement with a defined action</em></p></figcaption></figure>

{% hint style="info" %}
Demo request: demoStatementsPopup
{% endhint %}

## Defined events for the Slider <a href="#akcje-zdefiniowanezdarzeniadlaslidera" id="akcje-zdefiniowanezdarzeniadlaslidera"></a>

[Slider](https://github.com/Consdata/eximee-docs/blob/main/budowanie-aplikacji/interfejs-uzytkownika/formularze/biblioteka-komponentow-bazowych/slider.md) is able to handle an event defined in the validator (it must send the EMIT\_EVENT action in the error message). When adding an action, select from the action drop-down list an item from the list of allowed events, which is in turn defined in the validator implementation.

## Defined events for contextual help of the Text Field and Value Selection from List Field <a href="#akcje-zdefiniowanezdarzeniadlapomocykontekstowejpolatekstowegoipolawyboruwartoscizlisty" id="akcje-zdefiniowanezdarzeniadlapomocykontekstowejpolatekstowegoipolawyboruwartoscizlisty"></a>

For components: [Text Field - TextField](https://github.com/Consdata/eximee-docs/blob/main/budowanie-aplikacji/interfejs-uzytkownika/formularze/biblioteka-komponentow-bazowych/pole-tekstowe-textfield.md) and [Value selection field from list - Combobox](https://github.com/Consdata/eximee-docs/blob/main/budowanie-aplikacji/interfejs-uzytkownika/formularze/biblioteka-komponentow-bazowych/pole-wyboru-wartosci-z-listy-combobox.md) containing a label, you can define an action to open a popup when clicking the contextual help button. Before defining the action, add contextual help (tooltip) to the component.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FDKuDAFubgtsJsltD4fgX%2Fimage.png?alt=media&#x26;token=d09ba41c-cea5-4093-b8a8-c272ceb020f5" alt=""><figcaption><p><em><strong>Figure 7.</strong> Example of an action defined for the tooltip of the Text Field component</em></p></figcaption></figure>

{% hint style="info" %}
Demo requests: demoTextField, demoCombobox, demoPopup
{% endhint %}

## PageService as an action <a href="#akcje-pageservicejakoakcja" id="akcje-pageservicejakoakcja"></a>

If we define a PageService on the request, we can choose it in the section **Properties** - after selecting it, it is possible to choose the CALL action.

## Redirect action to a defined returnUrl <a href="#akcje-akcjaprzekierowanianazdefiniowanyreturnurl" id="akcje-akcjaprzekierowanianazdefiniowanyreturnurl"></a>

It is possible to attach an action (e.g. on clicking the Trigger) that will perform a redirect to ***returnUrl*** (REDIRECT\_TO\_RETURN\_URL), whose value is taken from a session variable with that name (the session variable ***returnUrl*** must be exposed).

## Redirect action to a defined URL <a href="#akcje-akcjaprzekierowanianazdefiniowanyurl" id="akcje-akcjaprzekierowanianazdefiniowanyurl"></a>

It is possible to attach an action (e.g. on clicking the Trigger) that will perform a redirect to the URL provided by the user, whose value is set when defining the action - REDIRECT.

The action will be performed even if a validator highlights some data as invalid.

## Parking action after entering a specific page <a href="#akcje-akcjaparkowaniapowejsciunakonkretnastrone" id="akcje-akcjaparkowaniapowejsciunakonkretnastrone"></a>

It is possible to define a parking action after entering a specific page: PARK\_FORM\_WITH\_PROVIDED\_HASH. Then you need to define the action for the page component (e.g. with the ON\_PAGE\_ENTER event). For the parking mechanism to work, remember to set the value of the session variable ***hashForUnparking***, which is needed to unpark the request.

## Action to enter a new request populated with a data model from a given process <a href="#akcje-akcjawejsciananowywniosekzasilonymmodelemdanychzpodanegoprocesu" id="akcje-akcjawejsciananowywniosekzasilonymmodelemdanychzpodanegoprocesu"></a>

It is possible to define an action for entering a new request that will initially be populated with a data model from a specific process. Then you need to define the START\_FORM\_BASED\_ON\_PROCESS action on the Trigger component. As part of this action, you need to configure the request name (**formName)** and **processInstanceId,** from which the model will be retrieved. Remember that **processInstanceId** must be a reference to a session variable, because only a **session variable is supported.**\
Currently, action configuration is not possible from the Designer; you need to use the "Source" tab. Example configuration below.

```
<formAction id="5392a77a-5b2b-4664-b918-b2b65004736f" handler="START_FORM_BASED_ON_PROCESS" event="CLICK">
  <formActionSources>
    <formActionSource>GesTrigger1</formActionSource>
  </formActionSources>
  <formActionParameters>
    <formActionParameter name="formName" value="esg_test_preview_wniosek"/>
    <formActionParameter name="processInstanceId" value="nazwaZmiennejSesyjnej"/>
  </formActionParameters>
</formAction>
```

## Actions - starting the Application <a href="#title-text" id="title-text"></a>

{% hint style="info" %}
The availability of the functionality depends on the license and may not be available in all deployments.
{% endhint %}

The START\_APPLICATION action is responsible for starting the process set as the starting point.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2Fc5QpqKiTAKWBcL6EyyTN%2Fimage.png?alt=media&#x26;token=f9302772-ab76-439f-959f-a9a49d438e11" alt=""><figcaption><p><em><strong>Figure 8.</strong></em> <em>Row for defining the START_APPLICATION action</em></p></figcaption></figure>

The START\_APPLICATION action takes the following parameters:

|                                   |                                                                                                                        |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| Application name                  | Indication of the process to be started.                                                                               |
| Redirect to the next process step | JAVASCRIPT condition. Indicates whether automatic redirection to the next user task should occur. Default value: false |

## Sample components sending events <a href="#akcje-przykladowekomponentywysylajacezdarzenia" id="akcje-przykladowekomponentywysylajacezdarzenia"></a>

| Component (action source)                             | Possible event    | Description                                                                  |
| ----------------------------------------------------- | ----------------- | ---------------------------------------------------------------------------- |
| Page (screen)                                         | NEXT              | Action when clicking the Next button on the request page                     |
| <p><br></p>                                           | ON\_EXIT          | Action on leaving the page                                                   |
| <p><br></p>                                           | ON\_PAGE\_ENTER   | Action on entering a specific page                                           |
| <p><br></p>                                           | SAVE\_DRAFT       | Action when clicking the temporary save button for the request               |
| Popup                                                 | SAVE              | Action when clicking the save button on the Popup component                  |
| <p><br></p>                                           | HIDDEN            | <p><br></p>                                                                  |
| Statements                                            | EDIT              | Action when clicking the edit button on the statements component             |
| Statements populated from the service (FedStatements) | EXPAND\_STATEMENT | Action when clicking the expander on the component with populated statements |
| Text Field (GesTextField)                             | TOOLTIP\_CLICKED  | Action when clicking the component tooltip                                   |
| Value Selection from List Field (GesCombobox)         | TOOLTIP\_CLICKED  | Action when clicking the component tooltip                                   |
| <p><br></p>                                           | VALUE\_CHANGED    | Action when changing the combobox value                                      |
| Trigger                                               | CLICK             | Action when clicking the component                                           |
| Checkbox                                              | CLICK\_MORE\_INFO | Action when clicking the more info link of the checkbox component            |
| <p><br></p>                                           | CHECK             | Action when checking the checkbox                                            |
| <p><br></p>                                           | UNCHECK           | Action when unchecking the checkbox                                          |
| RadioGroup                                            | VALUE\_CHANGED    | Action when changing the component value                                     |
| TileGroup                                             | VALUE\_CHANGED    | Action when changing the component value                                     |
| TileGroup                                             | TILE\_CLICKED     | Action when clicking a single tile in a tile group                           |

## Sample components receiving events <a href="#akcje-przykladowekomponentyodbierajacezdarzenia" id="akcje-przykladowekomponentyodbierajacezdarzenia"></a>

| Component handling actions                            | Type of form action              | Description                                                                                                                              |
| ----------------------------------------------------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| Checkbox                                              | CHECK                            | Checkbox checked                                                                                                                         |
| <p><br></p>                                           | UNCHECK                          | Checkbox unchecked                                                                                                                       |
| <p><br></p>                                           | TOGGLE                           | Changing the checkbox value to the opposite                                                                                              |
| Statements populated from the service (FedStatements) | CHECK\_FED\_STATEMENT            | Marks the required statement from the list of statements                                                                                 |
| Page (screen)                                         | FORWARD\_PAGE                    | Go to the next page (same as clicking the **Next**, **Submit application** button, etc.)                                                 |
| <p><br></p>                                           | BACKWARD\_PAGE                   | Go to the previous page (same as clicking the **Back**, **Back** button, etc.)                                                           |
| <p><br></p>                                           | REDIRECT\_TO\_RETURN\_URL        | Redirect to the URL defined in the session variable ***returnUrl***                                                                      |
| <p><br></p>                                           | REDIRECT                         | Redirect to the URL defined in the field available after selecting the REDIRECT action type                                              |
| <p><br></p>                                           | SAVE\_DRAFT                      | Temporary save of the request                                                                                                            |
| PageService                                           | CALL                             | Service call                                                                                                                             |
| Popup                                                 | SHOW\_POPUP                      | Opening a popup component defined in the field **Component handling the action**                                                         |
| <p><br></p>                                           | CLOSE\_POPUP                     | Closing the popup component                                                                                                              |
| <p><br></p>                                           | SAVE\_POPUP                      | Saving the popup component                                                                                                               |
| Attachments (Uploadfile)                              | CLEAR\_UPLOAD\_FILE              | Clearing the added attachment (works for the ON\_PAGE\_ENTER action)                                                                     |
| Form                                                  | PARK\_FORM\_WITH\_PROVIDED\_HASH | Parking the request                                                                                                                      |
| Trigger                                               | START\_APPLICATION               | Starting the process (the process set as the starting point) of the specified **applicationName** application                            |
| Trigger                                               | START\_FORM\_BASED\_ON\_PROCESS  | Action to enter a new request (formName parameter) populated with a model from the given process instance (processInstanceId parameter). |

{% hint style="info" %}
Demo requests: demoAkcje, demoTooltipy
{% endhint %}
