Activity Set - Advanced Trigger Condition

Averyy
Tera Contributor

Hello everyone,

We have this requirement to set trigger condition for one of our activity set.

Activity set only trigger when variable(u_sipr_email_required) is answered yes.

New to Dev, here is my script below

 

(function shouldActivitySetTrigger(parentCase /* GlideRecord for parent case */,
                              hrTriggerUtil /* hr_TriggerUtil script include instance */)
        {var siprNeeded = shouldActivitySetTrigger.getValue('u_sipr_email_required')
      if (siprNeeded == "yes");
return true;
})(parentCase, hrTriggerUtil);
4 REPLIES 4

Averyy
Tera Contributor

the variable 'u_sipr_email_required' is within a HR task, should I dot walk from the parent case within the script?

 

@Averyy Here is an example script where we are looking for the start date, an email address being populated and a previous activity set is completed. I hope this gives additional insight on how you can do this for your use case.

 

(function shouldActivitySetTrigger(parentCase /* GlideRecord for parent case */,

                                                                    hrTriggerUtil /* hr_TriggerUtil script include instance */) {

               

                var employeeStartDate = parentCase.subject_person_hr_profile.employment_start_date;

                var employeeCorporateEmail = parentCase.subject_person.email;

                var prerequisiteActivitySetIds = ['20f7a984ecb61300964fb378c82f556f'];

 

                //Check Corporate Email is populated

                if (gs.nil(employeeCorporateEmail))

                                return false;

               

                //Check Employee Start Date is populated and is on or before today

                if (gs.nil(employeeStartDate) || !hrTriggerUtil.checkForElapsedDate(employeeStartDate.getDisplayValue()))

                                return false;

               

                //Check Previous Set has finished

                if (!hrTriggerUtil.checkActivitySetsCompleted(prerequisiteActivitySetIds))

                                return false;

               

                return true;

 

If my answer has helped with your question, please mark my answer as an accepted solution and give a thumbs up.

Regards,

Mike

Hi @michaelj_sherid 

 

I have question related to  checkActivitySetsCompleted function. The prerequisiteActivitySetIds will the sys_id of the previous activity set ?

 

if (!hrTriggerUtil.checkActivitySetsCompleted(prerequisiteActivitySetIds))

                                return false;

@bhavishapadia Yes, the sys_ID of the previous Activity Set