Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Set the Watch List on TASK Based on List Collector Variable Selection

John Bone
Giga Expert

I have a List Collector variable called u_watch_list (refers to the sys_user table) on a catalog item where the requester can select any user(s) that they want to be added to the Watch List (watch_list) field on the TASK. I have tried several different approaches and I can't seem to get this to work. I have tried entering the different lines of script below into the Advanced section of the Catalog Task activity in the catalog item's workflow.

 

Here are some of my failed attempts: 

1. 

current.watch_list = current.variables.u_watch_list;

2. 

var watchList = current.variables.u_watch_list;
	if(watchList){
		current.watch_list = watchList.toString();
		current.update();
}

3. 

// initialize a blank array watchList
var watchList = [];
// u_watch_list is a comma separated list of strings

                if (current.u_watch_list) {
                    watchList=current.u_watch_list.split(",");
					task.watch_list = watchList.toString();
                }

 

Any help would be appreciated!

 

Thank you!

John Bone

 

1 REPLY 1

Peter Bodelier
Giga Sage

Hi @John Bone,

 

I just tested this one in my instance, and it seems to work fine.

current.watch_list = current.variables.u_watch_list;

 

Are you sure you are using the right field names?

Is there a reference qualifier defined on your watch_list field which prevents the users to be chosen?


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.