LB Events is Logic Builder extension that allows creating postponed events. Postponed event means that logic does not run immediately after changes are made but after a specified time.
LB Events can be used:
- when the execution of logic needs to be suspended for a certain time
- when the reaction to certain actions should occur after a specified time. Often such tasks are control tasks (for example, check Case Status in 24 hours)
Creating a new event consists of:
- Creating an event description in Sugar
- Describing the logic for generating and executing the event in Logic Builder.
Postponed event processing is initiated by the Sugar scheduler by the job ‘LB.Processing Suspended Events’.
Each run the job executes all events whose execution time is before the time of job execution. E.g. if an event was planned on 03-02-2022 15:47 and the job runs 03-02-2022 19:50, the postponed event will be executed.
Only one instance of Event can be generated for the record.
Let’s say there are two events:
- An event A generates whenever the Case Status is changed
- An event B generates whenever the Case Follow Up Date is changed.
Let’s say that in Case #4235 Status and Follow Up Date was Changed. As a result, both events A and B are generated.
Once Status is changed for Case #4235 and there is pending event A, the new event A will not be generated, but the Expired Date for the pending one will be updated.
How to create a new event?
Creating a new event consist of two parts:
- Creating an event and its parameters in Sugar in module LB Events.
- Configuring the logic of event generating and executing in Logic Builder.
In Logic Builder there are always 2 flowcharts of postponed events configuration:
- The first flowchart describes conditions of the postponed event generating and when it must be executed.
E.g. When the new Case is added generate an event in 24 hours to check whether it is still New
- The second flowchart describes what should happen when the postponed event is fired.
E.g. check whether the Case is still New and if yes – escalate it to Supervisor.
Creating an event in Sugar
The first step is to create an Event in Sugar. Once LB Events extension is successfully deployed, the new module LB Events is added into Sugar.
Navigate to LB Events module and create a new record specifying the following fields:
- Name – the name of the Event. Set the Name so you could easily understand the idea of this Event.
- Required: yes
- Required: yes
- Target Module – select from the list the module for which records postponed event is generated. E.g. if this event is to control the Case status, the Target Module is Cases
Note: If you don’t see the module in the list, please contact your administrator. Most likely you do not have access to this module
- Required: yes
- Context – specify the names of the parameters that are needed to be passed from the moment when the event is generated to the moment when the postponed event is executed.
These parameters are needed to preserve the context in which the event was generated since some data cannot be received at the time the postponed event is executed. For example, these may be the previous values of the fields for which the event is generated or a user, who modified the record.
It is possible to specify several Context parameters. Specify a name in the Argument Name. Click “+” next to the field to add another parameter.
Leave the field blank if you do not need to pass any parameters.
- Required: no
- Description – provide a description of the Event
- Required: no
An example of event generation: Let’s say it’s needed to control the status of the Case: when the Case is ‘Pending Input’ for more than 3 days – escalate it to Supervisor.
Also, we would like to check the previous status of this Case – what it was prior to ‘Pending Input’.
The described Event in Sugar:
Configuring the postponed event logic in Logic Builder
Once the Event is created in Sugar, the next step is to configure it in Logic Builder.
Configuring of logic that includes waiting for a certain time, always consists of two flowcharts:
The first flowchart describes the logic to create a postponed event. In this flowchart it’s needed to set the event parameters:
- which event should be generated and for which record
- when the event must be executed
- additional parameters, if they need to be passed from the time when an event is generated to the time when it will be executed.
To generate a postponed event use operator Generate Event:
Event Name – select the event from the list. All events created in Sugar (records of the LB Events module) are displayed here.
Try to update Sugar Metadata if there is no needed event in the list.
Id – specify the id of the record for which postponed event is generated.
For example, if you would like to check the status of a Case after a certain time, the id must contain the id of the Case record
Important! The input id must be from the module specified in the Target Module in the LB Event.
Date – specify the date and time when the event must be executed.
Additional data – select and fill with data context parameters that are needed to be preserved to the time when the postponed event is fired. The list shows all the context parameters specified for this Event in Sugar.
Continuation of the example: The first flowchart which generates the postponed event in 3 days looks like this:
The second flowchart describes what should happen when the time to execute the postponed event comes.
Start this flowchart from operator Process Event:
Event Name – select the name of the event from Sugar, for which it is needed to configure the logic.
Module – contains the name of the module for which the event is executed
ID – contains the ID of the record for which the event is executed
Additional Data – contains values that were set in the event generation flowchart (in operator Generate Event).
IMPORTANT! In the flowchart that implements the logic of event execution, it is necessary to check that all conditions for the execution of the event are still met. This is because the scheduled event is always executed at the specified time, regardless of any conditions that were specified in Generate Event flowchart.
Continuation of the example: in 3 days we are checking that Case is still Pending Input and if yes – update the assigned user to Supervisor:
Once two flowcharts are ready, both must be deployed into Sugar.
How to check what postponed events are scheduled?
To check which events are scheduled and for which records:
- Open the LB events record which scheduled events you would like to check
- Scheduled Events subpanel shows all pending events:
- Target record – the record for which the event was generated
- Date Expired – when the event will be executed
- Created By – who initiated the postponed event.
N.B.: Target Record may be empty for two reasons:
- it was removed from the system. In this case, when the time to execute the postponed event comes, it will not be executed and will be automatically deleted from the system.
- the record is not from the module specified in the Target Module. In this case, when the execution time of the postponed event comes, it will not be executed.
How to update LB Events?
It is possible to make the following changes to postponed events:
- Change the name of the event.
Open LB Events record and change the Name field. You do not need to make changes to the flowcharts.
- Change the module for which postponed events are generated.
Open the LB Events record and change the Target Module field. After that, update flowcharts that generate and process postponed events.
Important! When a module is changed, all pending events associated with this Event will not be executed.
- Change context parameters – add new and/or delete existing ones.
Open LB Events record and change the parameters in the Context field. After that, you need to make changes to the flowcharts that generate and process postponed event.
- Delete the Event. All associated pending events will be deleted too.
Can I Export and Import LB Events records?
Yes, you can migrate events from one Sugar instance to another using the standard Sugar export and import (for example, if you would like to deploy changes from sandbox to production).
The following fields must be imported:
- ID. If it is not possible to export-import an event record with an ID, then after creating a record on a new Sugar instance, it is necessary to update Sugar Metadata from the new Sugar instance and manually select the name of the LB Event record in the Generate Event and Process Event operators, following with deploying updated flowcharts on the instance.
- Name
- Target Module
- Context – if it was specified for the event
Note: When migrating LB Events records between Sugar instances, only the LB Events records are migrated. The logic described in Logic Builder is not migrated. To transfer the logic generated in the Logic Builder, you need to install the appropriate packages on the instance.
Can I apply to LB Events records Role restrictions?
Yes, standard Roles Configuration can be applied to the module LB Events.