List Collector Array in Run Script on Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 06:05 AM
Greetings:
I have been struggling with getting an array for a list collector on a catalog form to work. I want the below script to take the list of servers contained in the variable "select the server" and add them to the Affected CI's related list. If I select only one server in the list collector it will show that one server name in the related list, but if I select more than one it will not show the name of the server in the related list. So . . .choose one and the name of the server shows up, choose two and only one shows, but no server name. Can anyone tell me what I've got incorrect in the below script. I am using it on a run script within a workflow.
var answer =[];
var list = current.variables.select_the_server.toString(); \\ this is the variable name on the catalog form
var listArr = list.split(',');
for (var i=0;i<listArr.length;++i) {
var task_ci = new GlideRecord('task_ci'); \\ table name of Affected CI's releated List
task_ci.addQuery('sys_id',listArr[i]);
task_ci.query();
while(task_ci.next()){
answer.push(task_ci.ci_item.sys_id.toString());
}
}
Thanks
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 07:33 AM
Hi Nona,
Yes check that variable name is correct or not;
Also where this script is written?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 07:58 AM
yes the variable name is correct - I did double check that just in case. The script is written on a run script on the RITM workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 08:25 AM
Hi Nona,
That list collector variable is referring to which table?
Is that task_ci table?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2020 10:01 AM
Hi Nona,
Any update on this?
Can you mark answer as ✅ correct, 👍 helpful if you were able to achieve the requirement. This enables other members to learn from this thread.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 08:21 AM
Hi,
'select_the_server' variable on catalog form is referring to which table? Is it referring to 'task_ci' table?
If I have answered your question, please mark my response as correct and/or helpful.
Thanks,
Suseela P.