Group approval via script in workflow

mathiasjohansso
Kilo Expert

Hi guys!

I am struggling with an approval in a workflow.

So, I want to send an approval to a group, based on what division (company) that group belongs to (the company is referenced in a field on the sys_user_group-table; u_vendor).

I am trying to accompling this with a script in the Approval - Group action in the workflow, but the approval just won't get sent.

I have tried several varieties of the script, and the script runs correctly, but the approval won't send..

The "masterpiece":

var gr = new GlideRecord('sys_user_group');

var div = current.u_division.sys_id;

var group;

var answer =[];

gr.addQuery('u_vendor', div);

gr.query();

gs.log('Current division: ' + div);

gs.log('Records returned: ' + gr.getRowCount());

if(gr.next()){

  group = gr.sys_id;

  answer.push(group.toString());

  gs.log('group: ' + group);

  gs.log('answer: '+ answer);

}

From System Log

Untitled.jpeg

How can I get this to work?

Thanks!

1 ACCEPTED SOLUTION

anurag92
Kilo Sage

The script is perfect. I tried it (changing some variables) and it worked fine. Does the approval group has members?


View solution in original post

2 REPLIES 2

anurag92
Kilo Sage

The script is perfect. I tried it (changing some variables) and it worked fine. Does the approval group has members?


Hi!


Thanks! I was 100% sure that the groups had members, but when I double checked, they were empty..


Rookie mistake!


Thanks again!