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);
4 REPLIES 4

Wessel van Enk
Tera Guru
Tera Guru

Hi @Skydev22 ,

By default the non-mandatory tasks will not be checked before the next activity set is triggered. 
If you put the condition as ''Other activity set' and select the previous set, it should automatically get triggered once the mandatory tasks of the previous set are completed. It does not take the non-mandatory activities into account. 

@Wessel van Enk This is what i done first sorry but it is not working 

Allright, no worries. Did you do any modifications to the OOB workflows?

Sandeep Rajput
Tera Patron
Tera Patron

@Skydev22 Did you try running this script in a fix script/background script to see if it actually works?