passing an array to a workflow.scratchpad

poyntzj
Kilo Sage

I have a workflow that is used as a sub workflow.

I normally pass a number of variables from the instigating workflow to the sub workflow.

All nice and easy as so far it is just a single value each time.

 

An extra requirement has now been made and   I may need to pass a number of values in this one variable to the subworkflow.

On looking at the inputs i can see there is no "Array" so I may have to use string and seperator, however I do see an option of "List"

how would I

  • populate it to send to the sub workflow
  • get the sub workflow to read the list

 

Cheers

1 ACCEPTED SOLUTION

Had a little look into this now and i have going to send the information over as a string and then manipulate in the string in the sub workflow



my test script (looks at a change with a number of change tasks), it gets all the assignment groups and adds to a string.


I take that string, split and then get all the unique values before looking at what the query will do




//section for parent workflow


var strCtask = '';


var gr = new GlideRecord('change_task');


gr.addQuery('change_request','5cc3fd766fff5dc063e24c871e3ee423');


gr.query()


while (gr.next())


{


      strCtask += gr.assignment_group + '|'


}



gs.print(strCtask);




// section of sub workflow


if (strCtask != '')


{


      var inSplit = strCtask.split("|");


      var procArr = new ArrayUtil().unique(inSplit);


}



var aaggr = new GlideRecord('u_advanced_approval_groups')



if (procArr.length != undefined)


{


      if (procArr.length == 1)


              aaggr.addQuery('u_change_task_assignment_group','CONTAINS',procArr[0]);


      else if (procArr.length > 1)


      {


              oaaggr = aaggr.addQuery('u_change_task_assignment_group','CONTAINS',procArr[0]);


              for (var i=1; i < procArr.length ; i++)


              {


                      if (procArr[i] != '')


                              oaaggr.addOrCondition('u_change_task_assignment_group','CONTAINS',procArr[i]);


              }


      }


}



aaggr.query();


while (aaggr.next())


{


gs.print(aaggr.u_name);


}



View solution in original post

6 REPLIES 6

Hi,



I created a similar solution whereby I'm creating an array of objects that's being held as a workflow.scratchpad variable for Servic eCatalog requests (sc_req_item).



I had someone question whether this would cause performance issues if you have multiple open requests and therefore lots of these scratchpad variables in the system..   Is this likely to cause performance issues does anyone think???


gais
Tera Contributor

No .. it wont cause any performance issue