Is there a way to trigger an activity set based on a case form field in Kingston?

Pooja Reddy
Kilo Contributor

Hello,

I need to trigger an activity when a checkbox field on the parent case is checked (on the Kingston version). I am trying to use a script for the trigger condition but couldn't get it to work so far! If someone could help me figure out where I am going wrong, that would be brilliant!

Here's the script I'am using:

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

if (current.u_checkbox_case_field == true) {
return true;
} else {
return false;
}
})(parentCase, hrTriggerUtil);

Many thanks in advance!

1 ACCEPTED SOLUTION

michaelj_sherid
ServiceNow Employee
ServiceNow Employee

Try something like this in the Advanced Trigger. I am using a mycustom_field value from the parent (Lifecycle Event) case. Be aware that this trigger (Activity Set) will be evaluated on creation of the LE Case.

 

var gr = new GlideRecord('sn_hr_le_case');

if (gr.get(current.parent)) {

gr.u_mycustom_field = Yes; }

return true;

 

Regards,

Mike

View solution in original post

9 REPLIES 9

michaelj_sherid
ServiceNow Employee
ServiceNow Employee

Try something like this in the Advanced Trigger. I am using a mycustom_field value from the parent (Lifecycle Event) case. Be aware that this trigger (Activity Set) will be evaluated on creation of the LE Case.

 

var gr = new GlideRecord('sn_hr_le_case');

if (gr.get(current.parent)) {

gr.u_mycustom_field = Yes; }

return true;

 

Regards,

Mike

Hi Mike,

Thanks so much for your prompt response! This script works when I update the checkbox before the LE case moves to 'work in progress' state but not if I update it after. 

However, I need this activity triggered not on creation but on change to the LE Case. But I am guessing that isn't possible due to the way activity sets are designed, and as you say the trigger is evaluated on creation and not on change!

Thanks again though, really appreciate your help!

 

 

 

 

You are correct, the activity set will not be evaluated on modification of the LE Case. 

Hi Mike

I am trying to use your solution above but it isn't working for me.  I have the employee transfer field on the onboarding form mapped to the employee transfer column on the sn_hr_le_case table.  Am I missing something?

My form field is a yes/no but it doesn't seem to write to the table which what I think is the problem. 

Any help would be very appreciative.

 

thank you

 

Jen

(function shouldActivitySetTrigger(parentCase /* GlideRecord for parent case */,
         hrTriggerUtil /* hr_TriggerUtil script include instance */) {
var gr = new GlideRecord('sn_hr_le_case');


if (gr.get(current.parent)) {


gr.u_employee_transfer = Yes; }

 

 return true;  

})(parentCase, hrTriggerUtil);