Lifecycle Events triggers and workflow reference
Summarize
Summary of Lifecycle Events triggers and workflow reference
This document explains how Lifecycle Events triggers and workflows operate within the ServiceNow Human Resources (HR) Lifecycle Events framework, particularly focusing on how activity sets are launched and managed when a lifecycle event case changes states. It highlights key components such as the HR Activity Launcher flow, trigger conditions, evaluation intervals, and alternative triggering methods including server-side scripting and events.
Show less
HR Activity Launcher Flow and Trigger Evaluation
- When a lifecycle event case moves to the Ready state, all activity sets are processed through the HR Activity Launcher flow.
- Activities within each set are triggered only if their specific trigger conditions are met.
- If trigger conditions are unmet, the system waits for a Wait to reevaluate Trigger Script timer (default every 4 hours) before rechecking.
- The evaluation interval is controlled by the evaluationinterval field in the
snhrleactivitysettable, which can be adjusted to reduce trigger delays but should be done cautiously to avoid premature cancellations.
Alternative Triggering: Condition with Event BR (Demo) Activity Set
- This optional method uses a demo activity set and associated business rule to trigger activity sets based on lifecycle event case state changes, specifically when the case moves to Work in Progress.
- It requires activation of the Human Resources Scoped App: Lifecycle Events for Enterprise (com.snhrlifecycleent) plugin.
- The business rule broadcasts a
checkactivitysettriggerevent to the HR Activity Set Trigger Check workflow to prompt immediate reevaluation. - Customers can customize the demo activity set, email activity, and business rule to fit their specific requirements.
HR Activity Set Trigger Check Workflow
- This workflow is integrated into the HR Activity Launcher to enable server-side scripts to notify it to check if activity set trigger conditions are met.
- It regularly evaluates trigger conditions but does not directly trigger activities.
- If the
checkactivitysettriggerevent is fired, it triggers immediate reevaluation without waiting for the scheduled timer.
Using the checkactivitysettrigger Workflow Event
- Customers can use this event in server-side scripts (business rules, event scripts, scheduled jobs) to bypass the default timer and evaluate trigger conditions just-in-time.
- This approach is recommended over shortening the evaluation interval timer to avoid excessive event firing and activity cancellations.
- The event does not apply to activity sets that are triggered immediately or solely by other activity sets.
- To implement, identify the server-side logic location where trigger criteria become true, then add the provided script snippet to broadcast the event to the HR Activity Set Trigger Check workflow.
Information about Lifecycle Events triggers and workflow.
HR Activity launcher flow
When a lifecycle event case is changed to the Ready state, all activity sets run through the HR Activity Launcher flow. The activities in each activity set aren’t triggered. When an activity set isn’t dependent on other activity sets to trigger activities, the trigger conditions are analyzed.
If the trigger condition hasn’t been met, it waits for the Wait to reevaluate the Trigger Script timer to run (default is every four hours).
If the trigger condition is met, but after the evaluation interval runs, it has to wait another four hours before the activities set is reevaluated. Waiting for reevaluation can cause delays in an activity set to trigger.
The Wait to reevaluate Trigger Script timer uses the evaluation_interval in the sn_hr_le_activity_set table. The default value is four hours. You can reduce the value in the evaluation_interval field to launch the activity set sooner, see Change the evaluation interval default wait time.
Condition with Event BR (Demo) activity set
- The trigger type for the activity set must be set to Condition.
- The Condition with Event BR (Demo) activity set triggers when the state of primary lifecycle event case moves to Work in progress.
- The Email - Condition with Event BR (Demo) activity is included with the Condition with Event BR (Demo) activity set.
- The Condition with Event BR (Demo) activity set includes the
HR Activity Launcher workflow. It also includes the
Condition with Event BR (Demo) business rule.
- The Condition with Event BR (Demo) business rule runs after the state of an LE case changes to Work in Progress.
- It then looks for the workflows that are running for the LE case until it finds the HR Activity Set Trigger Check workflow and broadcasts the check_activity_set_trigger event to that workflow.
- You can change the Condition with Event BR (Demo) activity set,
Email - Condition with Event BR (Demo) activity, and
Condition with Event BR (Demo) business rule to fit your
requirements.Note:For more information, see Lifecycle Events workflows and Business rules.
HR Activity Set Trigger Check workflow
- The HR Activity Set Trigger Check workflow is called when an activity set isn’t dependent on other activity sets.
- It regularly checks if the trigger condition for an activity set has been met.
- If the trigger conditions haven’t been met, it still waits for the evaluation interval to run.
- If the check_activity_set_trigger event fires, the Activity set trigger conditions are checked immediately.
Check activity set trigger workflow event
- script include
- scheduled job
- import script
After you've determined the server-side location to check the trigger criteria, add the following script to it:
(function executeRule(current, previous /*null when async*/) {
var wf = new global.Workflow().getRunningFlows(current);
while (wf.next()) {
if (wf.getValue('name') !== 'HR Activity Set Trigger Check')
continue;
new global.Workflow().broadcastEvent(wf.sys_id, 'check_activity_set_trigger');
}
})(current, previous);