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.

Trigger activity set based on mandatory task of the previous activity set

Skydev22
Tera Contributor

Hello Community, I have a requirement where I need to trigger an activity set when all the mandatory tasks (optional = false) in the previous activity set are completed. Here is what I have done in the advanced trigger, but it still isn't working. Anyone can help with this, please? 

 

 

(function shouldActivitySetTrigger(parentCase /* GlideRecord for parent case */ ,
    hrTriggerUtil /* hr_TriggerUtil script include instance */ ) {


    var grTask = new GlideRecord("sn_hr_core_task");
    grTask.addEncodedQuery('parent.sys_id='+parentCase.sys_id.toString()+'^optional=false^sn_hr_le_activity.ref_sn_hr_le_activity.activity_set=b525e12f335c5e1074abc1c13d5c7b46');
    grTask.query();

    while (grTask.next()) {

        if (grTask.state != 3) {
            gs.info("Required task still open: " + grTask.number);
            return false;
        }
    }

    gs.info("All required tasks completed for case: " + parentCase.number);
    return true;

})(parentCase, hrTriggerUtil);
0 REPLIES 0