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 ServiceNow's Human Resources (HR) Lifecycle Events framework. It focuses on managing activity sets tied to lifecycle event cases, detailing how and when these activities initiate based on specific conditions and timing intervals. The content is relevant for customers configuring or optimizing HR Lifecycle Event workflows to ensure timely and efficient activity triggering.
Show less
HR Activity Launcher Flow and Activity Set Triggering
When a lifecycle event case transitions to the Ready state, all associated activity sets are processed through the HR Activity Launcher flow. However, activities within each set only trigger if their specific trigger conditions are met. If conditions are unmet, the system waits for a timer (default interval of four hours) to reevaluate these conditions. This wait can introduce delays in triggering activities.
The reevaluation interval is controlled by the evaluationinterval field in the snhrleactivityset table. Customers can reduce this interval to accelerate activity triggering, but caution is advised as shorter intervals may cause increased event processing and potential activity cancellations before completion.
Alternative Triggering Using Condition with Event BR (Demo) Activity Set
Instead of relying solely on the evaluation interval timer, customers can use the Condition with Event BR (Demo) activity set, which is included in demo data and activated via the Human Resources Scoped App: Lifecycle Events for Enterprise (com.snhrlifecycleent) plugin.
- This method uses a business rule to detect when a lifecycle event case state changes to Work in Progress and then fires a checkactivitysettrigger event to prompt immediate evaluation of trigger conditions.
- The trigger type of the activity set must be set to Condition to use this method.
- The demo includes an email activity and business rule which can be customized to fit specific customer requirements.
HR Activity Set Trigger Check Workflow
This workflow is integrated into the HR Activity Launcher to allow server-side scripts (such as business rules or scheduled jobs) to notify the workflow to immediately check if an activity set is ready to trigger, bypassing the default wait interval.
- It regularly evaluates trigger conditions for activity sets that are independent of other sets.
- If trigger conditions are not met, it waits for the evaluation interval; if the checkactivitysettrigger event is fired, it evaluates conditions immediately.
- It does not directly trigger workflows but prompts evaluation of conditions.
Using the checkactivitysettrigger Workflow Event
Customers can use the checkactivitysettrigger workflow event in server-side scripts to prompt just-in-time evaluation of activity set triggers, effectively bypassing timer delays without shortening the evaluation interval.
- This is especially useful to avoid long wait times without increasing event frequency.
- The event does not apply to activity sets triggered immediately or exclusively by other activity sets.
- To implement, identify where the activity set’s trigger conditions are checked server-side, then add a script snippet that broadcasts the checkactivitysettrigger event to the HR Activity Set Trigger Check workflow.
Practical Application for ServiceNow Customers
ServiceNow customers managing HR Lifecycle Events can leverage these workflows and triggers to:
- Control when activities launch based on lifecycle event case states and conditions.
- Optimize timing by adjusting evaluation intervals or using event-driven triggers to reduce delays.
- Customize demo-provided business rules and activity sets to meet organizational needs.
- Use server-side scripting to programmatically trigger immediate checks, enhancing responsiveness and efficiency of lifecycle event processing.
Understanding these mechanisms helps ensure lifecycle event activities are triggered accurately and timely, improving HR process automation and case management.
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);