> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# EventData

> EventData gives you access to contextual information in an event handler.

**EventData** gives you access to contextual information in an **event handler**. For example, the name of a created company or the amount of a sale.

You can also check `EventData` properties after the event handler has run, to for example display a message or prevent an entity from being saved.

## Example

Check if a sale has a high enough value. Return a message and block the sale for values \< 100. Set for the event "Before save sale".

```crmscript theme={null}
EventData ed = getEventData();

if (ed.getInputValue("SaleEntity.Amount").toInteger() < 100)
{
  ed.setBlockExecution(true); // Prevents save
  ed.setMessage("Amount too low");
}
```

## Fetch variables used in the current context

```crmscript theme={null}
EventData ed = getEventData();
```

<Note>
  EventData doesn't work with manually run scripts!
</Note>

## Type

The types of events that can occur pertain to either \[Service screen events]\[1] (`beforeSetFromCgi`, `afterSetFromCgi`, `beforePrint`) or triggers.

* Integer `getType()`

## Input values

**Input values** are for getting available data - a **read** operation. You can either fetch a specific value or a Map with all values.

* String [getInputValue(String inputValue)][5]
* Map [getInputValues()][6]

## Output values

**Output values** are for setting (or changing) data - a **write** operation. They are frequently set on a  *before save* trigger to get better data quality.

* Void [setOutputValue(String name, String value)][7]

## Custom values

In addition to the built-in input and output values, you can also set and get **custom values**. These are also called **state values** and work just like setting and getting the standard values. The only difference is that **naming** the custom variables is up to you.

| Method         | Description        | Equivalent to  |
| :------------- | :----------------- | :------------- |
| getStateValue  | Get specific value | getInputValue  |
| getStateValues | Get all values     | getInputValues |
| setStateValue  | Set specific value | setOutputValue |

After you set a custom value, it can be accessed - also by other `EventData` objects in the same script.

<Note>
  From version 10.5.2, we support listening for a command in StateValue to close Ticket tabs from CRMScript triggers in the Sales client.
</Note>

This can be done by [adding a StateValue][16] **command:ticket.tab.close**.

## Open dialog to handle user interaction

<Note>
  From version 10.1.9 we support generating a dialog from CRMScript triggers in Sales client.
</Note>

In certain scenarios, it can be necessary to ask the user for input or confirmation before completing process, using this method we allow for creating a simple dialog which will return input back to CRMScript trigger. Use this to construct a useful workflow.

* Void [showDialog(EventDataDialogDefinition dialog)][15]

## Messages

* String [getMessage()][8]
* Void [setMessage(String message)][9]

## Validation and blocking actions

* Bool [getBlockExecution()][10]
* Void [setBlockExecution(Bool value)][11]
* Void [setValidationMessage(String message)][12]

### Setting criteria with a Map instead of multiple OR conditions in an if statement

```crmscript theme={null}
Map sourceIds;
sourceIds.insert("11", "");
sourceIds.insert("128", "");
sourceIds.insert("135", "");

if (sourceIds.exists(sourceId.toString())){
  // ...
}
```

## Navigation

Navigation uses \[SOProtocol]\[2] and \[URL parameters]\[3].

* String [getNavigateTo()][13]
* Void [setNavigateTo(String url)][14]
  \[1]: ../../../ui/blogic/screen-events
  \[2]: ../../../customization/soprotocol/index
  \[3]: ../../../ui/blogic/url-parameters

[5]: /en/automation/crmscript/reference/CRMScript.Native.EventData#getinputvaluestring

[6]: /en/automation/crmscript/reference/CRMScript.Native.EventData#getinputvalues

[7]: /en/automation/crmscript/reference/CRMScript.Native.EventData#setoutputvaluestringstring

[8]: /en/automation/crmscript/reference/CRMScript.Native.EventData#getmessage

[9]: /en/automation/crmscript/reference/CRMScript.Native.EventData#setmessagestring

[10]: /en/automation/crmscript/reference/CRMScript.Native.EventData#getblockexecution

[11]: /en/automation/crmscript/reference/CRMScript.Native.EventData#setblockexecutionbool

[12]: /en/automation/crmscript/reference/CRMScript.Native.EventData#setvalidationmessagestring

[13]: /en/automation/crmscript/reference/CRMScript.Native.EventData#getnavigateto

[14]: /en/automation/crmscript/reference/CRMScript.Native.EventData#setnavigatetostring

[15]: /en/automation/crmscript/reference/CRMScript.Native.EventData#showdialogeventdatadialogdefinition

[16]: ../tutorials/closing-request-tabs-in-triggers


## Related topics

- [EventData](/en/automation/crmscript/reference/CRMScript.Native.EventData.md)
- [SuperOffice.WebApi.Data.EventData](/en/api/reference/webapi/SuperOffice.WebApi.Data.EventData.md)
- [Execute Event Handlers](/en/api/reference/restful/agent/customerservice_agent/execute-event-handlers.md)
- [Execute Script As Event](/en/api/reference/restful/agent/crmscript_agent/execute-script-as-event.md)
- [EventDataDialogDefinition](/en/automation/crmscript/reference/CRMScript.Native.EventDataDialogDefinition.md)
- [EventDataDialogField](/en/automation/crmscript/reference/CRMScript.Native.EventDataDialogField.md)
