Why is my Workflow script not triggering approval to various groups?

AbdurRahmanSnow
Giga Guru

Good afternoon.
Why is my Workflow script not triggering approval to various groups? Approvals are getting skipped. Please check my code below:

// Set the variable 'answer' to a comma-separated list of group ids or an array of group ids to add as approvers.
//
// For example:
//       var answer = [];
//       answer.push('id1');
//       answer.push('id2');

var answer = [];

current.variables.which_im_emea_group == 'IM_EMEA_Food';
workflow.info('Line 11 ' + current.variables.which_im_emea_group);

if(current.variables.which_im_emea_group == 'IM_EMEA_Food'){
    workflow.info('Line 14: ' + current.variables.which_im_emea_group)
    answer.push('6c1ed1cfc3242610cd77314c05013113');
    workflow.info('Line 16 ' + answer.push('6c1ed1cfc3242610cd77314c05013113'));
}
else if(current.variables.which_im_emea_group == 'IM_EMEA_Egypt_Energy'){
    answer.push('471ed5cfc3242610cd77314c05013127');
}
else if(current.variables.which_im_emea_group == 'IM_EMEA_Healthcare'){
    answer.push('be1e95cfc3242610cd77314c0501318b');
}
else if(current.variables.which_im_emea_group == 'IM_EMEA_Cruise'){
    answer.push('5f1ed5cfc3242610cd77314c050131a7');
}
else if(current.variables.which_im_emea_group == 'IM_EMEA_Industrial_Maritime'){
    answer.push('851ed1cfc3242610cd77314c050131a5');
}
else if(current.variables.which_im_emea_group == 'IM_EMEA_Pharma'){
    answer.push('7a0edd8fc3242610cd77314c05013192');
}
else if(current.variables.which_im_emea_group == 'IM_EMEA_Türkiye'){
    answer.push('d60edd8fc3242610cd77314c05013102');
}
else{
    answer.push('a30e51cfc3242610cd77314c05013116');
}
1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

What are you seeing in the logs?  Are the values you are pushing to the answer variable in each if statement confirmed to be sys_ids from the sys_user_group table?  Have you tested with various im_emea_group selections? Do the groups you are testing with have at least one active user?  Are you using the Approval - Group activity as opposed to Approval - User?

View solution in original post

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

What are you seeing in the logs?  Are the values you are pushing to the answer variable in each if statement confirmed to be sys_ids from the sys_user_group table?  Have you tested with various im_emea_group selections? Do the groups you are testing with have at least one active user?  Are you using the Approval - Group activity as opposed to Approval - User?

Oh, @Brad Bowman  . Correct.

Code was working correct, but there were no users in those groups. 😂🤣
I spent 2-3 hours figuring this out and found it with your help.
Thank you so much.

You are welcome.  I have done the same.  It would be nice if the 'skipped' message indicated why.