Workflow Approval based on List Collector Variable

Sandy7
Tera Expert

Hi Everyone -

I have a Service Request w/ Workflow tied to it and need to do the following:

1 - I have a variable that is a list collector. I pasted a screenshot of the associated table from where the list collector pulls the data:

The Override Group Setting is the value(s) selected on the Service Request, and the Functional Approval Group is the associated group that needs to approve if that particular override group setting is selected

find_real_file.png

 

2- I am not sure how to set this up ... has anyone been able to make this work successfully? 

I know I need to set up a Group Approval with Advanced checked, but I am unsure of the syntax to use within that activity. I had the following script below I was testing with but that does not seem to work.. it is automatically approving .. 

// 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 group = current.variables.override_settings; //this is the variable name
var getGroupValue = new GlideRecord('u_override_settings'); //this is the table name
getGroupValue.addEncodedQuery('u_override_group_setting'='+group); //this is the column on the table that is the group setting selected
getGroupValue.query();
if(getGroupValue.next())
answer.push(getGroupValue.u_functional_approver_group.toString()); // this is the asscociated approver group

14 REPLIES 14

What values does u_override_group_setting stores? is it name of group?

HI, no that is not the name of the group, it is the Override Group Setting (so the column on the very left in the screenshot).

Can you try this

var answer = [];

var group = current.variables.override_settings; //this is the variable name
var getGroupValue = new GlideRecord('u_override_settings'); //this is the table name
getGroupValue.addQuery('sys_id', 'IN',group); //this is the column on the table that is the group setting selected
getGroupValue.query();
while(getGroupValue.next()){
answer.push(getGroupValue.u_functional_approver_group.toString()); // this is the asscociated approver group
}

Hello,

So I tried that and on the Group Approval action(This is where I put the script), it automatically approves it and advances the workflow. I would expect it to create an approval for that group.

The log returns this:

Group: ffd3e6194fbbab40acfcecee0210c754 which is the sys id for the Override Setting selected. 

Is u_functional_approver_group a reference field pointing to group or is it a string field saving the group name?