How to trigger second activity set based on the advance condition and audience

vijani
Tera Expert

Hello All, I want to trigger the current activity set based on audience criteria if the previous activity set was not triggered due to its task conditions.
I have set the trigger type to ‘Advanced’ with conditions based on the previous activity set and its tasks. It works as expected when the previous activity set is triggered. However, if the previous activity set is not triggered, the current activity set does not trigger based on the assigned audience. so may i know how to fix this.
Help would be highly appreciated.

   (function shouldActivitySetTrigger(parentCase /* GlideRecord for parent case */,
                                   hrTriggerUtil /* hr_TriggerUtil script include instance */) {
 
    var parentCaseSysId = parentCase.getValue('sys_id');
     var hrService = gs.getProperty('sn_hr_core.service');
 
    // Previous Activity Set IDs to check
    var previousActivitySetIds = ['f72a18a01bb886540b9a11739b4aab78'];
    
    // Check if previous activity sets are completed
    if (hrTriggerUtil.checkActivitySetsCompleted(previousActivitySetIds)) {
         var grTask = new GlideRecord('sn_hr_core_case_talent_management');
        grTask.addQuery('parent', parentCaseSysId);
        grTask.addQuery('hr_service', hrService);
        grTask.addQuery('state', '3'); // Closed Complete
        grTask.addQuery('approval', 'approved');
           grTask.query();
             if (grTask.next()) {
         
            return true;
        } else {
                        return false;
        }
       }
 
})(parentCase, hrTriggerUtil);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             @michaelj_sherid                                                                                                                                                                                                                                                                                                                                                                                                                           
3 REPLIES 3

Kieran Anson
Kilo Patron

Hi,

If you navigate to the sn_hr_le_activity_set_context table, and filter on the case you're using for testing, do you see the activity set listed? What state is it in?

Hi @Kieran Anson the state is showing skipped

Thanks for confirming, if you add logging, does the if statement log out? It should based on the function checking for activities not in a state of 'finished'

 

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

     var parentCaseSysId = parentCase.getValue('sys_id');
     var hrService = gs.getProperty('sn_hr_core.service');

     // Previous Activity Set IDs to check
     var previousActivitySetIds = ['f72a18a01bb886540b9a11739b4aab78'];

     // Check if previous activity sets are completed
     if (hrTriggerUtil.checkActivitySetsCompleted(previousActivitySetIds)) {
		gs.info('HRLog - Checking Activity State');
         var grTask = new GlideRecord('sn_hr_core_case_talent_management');
         grTask.addQuery('parent', parentCaseSysId);
         grTask.addQuery('hr_service', hrService);
         grTask.addQuery('state', '3'); // Closed Complete
         grTask.addQuery('approval', 'approved');
         grTask.query();
         if (grTask.next()) {
				gs.info('HRLog - Checking Activity State - Found Case');
             return true;
         } else {
			gs.info('HRLog - Checking Activity State - Did Not Find Case');
             return false;
         }
     }

 })(parentCase, hrTriggerUtil);