Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 51 Next »

You’re using Event Hook logic when you need to:

  • run a piece of code at the moment, when certain event/action happens in the system, e.g.:

    • for quote you can place hook before the quote is converted to deal, and you can stop this transition depending on some calculation.

    • you can send email notification to certain people

Logic API

  • Logic Nature: eventHook

    • Logic Type: Calculation/Pricing

  • Execution Types:

    • Standard - to perform some calculation and return the decision (if any)

  • Information provided to the logic

    • depends on the type of the hook event (see list of all hook events at HookEventType) for which it is triggered. For event

      • QUOTE_TO_DEAL_PRE

        • binding variable quote - with content of the quote (incl. items), but it has only simple built-in fields, and does not contain any information about inputs and outputs (not for header nor for items). So if you need the complete quote content, you need to read from database.

  • Expected logic execution outcome

    • depends on the type of the hook event (see list of all hook events at HookEventType) for which it is triggered. For event

      • QUOTE_TO_DEAL_PRE - system will use only result and message from the first logic element. The result must be of type boolean.

        • if the result type is NOT Boolean, the result and message is ignored, and the action can continue with execution

        • TRUE - the action can continue with execution

        • FALSE - the action is NOT allowed to continue, and the message will be used and displayed to the user

        • exception - the action is NOT allowed to continue, and the exception message will be used and displayed to the user

Logging/Testing

The hook events are logged to the Hook Events (HEVT) table.

Configuration

Configured as Advanced Configuration Options on page Administration  Configuration  System Configuration  Advanced Configuration Options

The configuration option is called eventHooksConfig. There can be more various event types, that’s why the configuration is a list. But you can have only one logic for one event type.

The event is trigger either PRE or POST the action.

Example of "eventHooksConfig" advanced configuration option
[
  {
    "event": "QUOTE_TO_DEAL_PRE",
    "label": "Convert quote to deal pre-execute",
    "logicName": "EventHook_QuoteToDealPre"
  }
]

Code Sample

Example of simple QUOTE_TO_DEAL_PRE event hook logic
def completeQuote = api.getCalculableLineItemCollection(quote.typedId)  //❶

if (libs.QuoteSharedLib.utils.isIndicativePricingQuote(quoteWithItems)) {
    api.setAlertMessage("Indicative Pricing Quotes cannot be converted into a Deal")
    return false
}

return true

❶ variable "quote" has only simplified Quote data, if you want complete info, you need to read from database

  • No labels