How do up update the value of a list collector in server side script???

DrewW
Mega Sage
Mega Sage

I have a catalog item were the user selects a list of groups. Then in the workflow I need to update that list collector then then allow the tech who is going to do the work review the items that are selected and then either select more items or remove items. The issue I am having is that in the workflow I update the selections that the user made but it does not save them.

I have tried the following methods of updating the value of the list collector to no avail.

current.variables.removeuser = removeListArray;
current.variables.removeuser.setValue(removeListArray);
current.variables.removeuser = removeListString;
current.variables.removeuser.setValue(removeListString);

Does anyone know how you can do this?

10 REPLIES 10

Mark Stanger
Giga Sage

Should just be a comma-separated string of sys_id values. I was able to get the following to work on demo just now...

rec.variable_pool.test = '52bea575f060100000e6fda62efbc97d,c9884ac30a0a0bdb3879454e8f02774e';


DrewW
Mega Sage
Mega Sage

Then I must be having another issue because my code is below and it does not work.



gs.log("Workflow: SNC Group: groups: " + current.variables.group.toString());
//var removeList = "";
var removeList = new Array();
var addList = new Array();
var currentList = new Array();

//Find groups to remove.
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("user", current.variables.user);
gr.addQuery("group", "NOT IN", current.variables.group.toString());
gr.query();
while(gr.next()){
removeList.push(gr.sys_id);
}
gs.log("Workflow: SNC Group: removeList: " + removeList);
current.variables.removeuser = removeList.toString();

current.update();


Try changing this...
current.variables.removeuser = removeList.toString();

to this...
current.variables.removeuser = removeList.join();


DrewW
Mega Sage
Mega Sage

Nope, that did not work either. I am starting to wonder if it is some kind of odd timing issue.