Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Conditional Lifecycle Event Activities

Michael C1
Giga Contributor

Hi all,

I'm trying to build a Lifecycle Event which has numerous Activities which need to be created or not created based on conditions of the Lifecycle Event Case record itself.

Example:

LE Case created with a checkbox field on sn_hr_le_case. Based on the value of the checkbox, how can an Activity be conditionally triggered? Not an Activity Set - that's easy due to Advanced Trigger type allowing scripted conditions. But I can't see a way to use script nor condition builder for individual Activities.

I can see HR Criteria, but can I use this to query the value of the fields on the current LE case record? It seems like HR Criteria is for things like users department, location, etc. Can I somehow use this to refer to the current sn_hr_le_case?

Thanks in advance for any advice!

Regards,

Michael

5 REPLIES 5

TahiraS
Tera Expert

I have a similar situation and I was wondering if there is a solution for this

 

I want the activity set to get triggered based on the value of one of the fields on the parent case.  I tried the script but its not getting triggered:

I'm not sure how to utilize audience since we want to look at the previous step for the current lifecycle case.

This is the script I'm using, please help

 

(function shouldActivitySetTrigger(parentCase /* GlideRecord for parent case */,
                              hrTriggerUtil /* hr_TriggerUtil script include instance */) {
        var gr = new GlideRecord('sn_hr_le_case');
        gr.addQuery('parent', parentCase.sys_id.toString());
        gr.addQuery('field`''Fail');
        gr.query();
       
        if (gr.next())
            return true;  
        else
            return false;
})(parentCase, hrTriggerUtil);