Creating a group approval

hugogomes
Giga Expert

Hi community,

it is the first time I'm trying to set a group approval for an item.

For the catalog Item we are using the OOB related list to add the groups to approve the request. For what I was able to see that list is related with the sc_cat_item_app_group table.

I have based myself on this tread to create my script, Re: Group Approval so what I did was very similar:

var answer = [],  

          arr = current.group_list.toString(),  

          group;

var group = new GlideRecord('sc_cat_item_app_group');  

group.addQuery('sys_id', 'IN', arr);  

group.query();  

while(group.next()){  

      answer.push(group.approval_group + '');  

      workflow.debug('user approval' + group.u_approval_group);  

      workflow.debug('approval: ' + answers);  

}

My first question is the variable, current.group_list, I have used the ones available on the right side of the script field. Is this the correct one? Or should be used in a different way?

The result of this activity is "skipped", so there is no need to refer that it is not quite as I expect.

Any advise on this?

Thank you

1 ACCEPTED SOLUTION

hugogomes
Giga Expert

To make this work I used the solution that can be found here: Re: RITM Group Approval on Workflow



  1. var answer = (function() {  
  2.   var groups = [];  
  3.   var gr = new GlideRecord("sc_cat_item_app_group");  
  4.   gr.addQuery("sc_cat_item", current.getValue("cat_item"));  
  5.   gr.query();  
  6.   while (gr.next()) {  
  7.         groups.push(gr.getValue("approval_group"));  
  8.   }  
  9.   return groups;  
  10. })();


Thank you for your help!


View solution in original post

4 REPLIES 4

SanjivMeher
Kilo Patron
Kilo Patron

You just need to do below and it should work.


var answer = [];       answer = current.group_list.toString(),



Please mark this response as correct or helpful if it assisted you with your question.

Thank you for your reply.



It doesn't work, it is still skipping the approval.


SanjivMeher
Kilo Patron
Kilo Patron

var answer = '';       answer = current.group_list.toString(); gs.log('++++++++++my group list is '+current.group_list.toString());


Try the above code. Also check system log, what value is printed gor group_list.



I think you may need to change it the current.variables.group_list.toString(), if it is a variable and not field.


For variables use


var answer = '';       answer = current.variables.group_list.toString(); gs.log('++++++++++my group list is '+current.variables.group_list.toString());



Please mark this response as correct or helpful if it assisted you with your question.

hugogomes
Giga Expert

To make this work I used the solution that can be found here: Re: RITM Group Approval on Workflow



  1. var answer = (function() {  
  2.   var groups = [];  
  3.   var gr = new GlideRecord("sc_cat_item_app_group");  
  4.   gr.addQuery("sc_cat_item", current.getValue("cat_item"));  
  5.   gr.query();  
  6.   while (gr.next()) {  
  7.         groups.push(gr.getValue("approval_group"));  
  8.   }  
  9.   return groups;  
  10. })();


Thank you for your help!