• Share
    • Twitter
    • LinkedIn
    • Facebook
    • Email
  • Feedback
  • Edit
Show / Hide Table of Contents

EventData

•
Version: 10.5.2
Some tooltip text!
• 3 minutes to read
 • 3 minutes to read

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".

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

EventData ed = getEventData();
Note

EventData doesn't work with manually run scripts!

Type

The types of events that can occur pertain to either Service screen events (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)
  • Map getInputValues()

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)

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.

This can be done by adding a StateValue 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.

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)

Messages

  • String getMessage()
  • Void setMessage(String message)

Validation and blocking actions

  • Bool getBlockExecution()
  • Void setBlockExecution(Bool value)
  • Void setValidationMessage(String message)

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

Map sourceIds;
sourceIds.insert("11", "");
sourceIds.insert("128", "");
sourceIds.insert("135", "");

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

Navigation

Navigation uses SOProtocol and URL parameters.

  • String getNavigateTo()
  • Void setNavigateTo(String url)
In This Article
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top