- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2022 11:02 AM
I added a list collector variable to a form, but the selected names don't show up on the RITM or SCTASK watchlist.
How do I do this? It won't let me select the Field to map to.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 09:23 AM
A workflow Run Script runs on the sc_req_item table, so to set the RITM watch_list field the same as your watch_list variable, you would just need this line:
current.watch_list = current.variables.watch_list;
To set the watch_list field on Catalog Task(s), you can also include a GR to the sc_task table, but this must be done after the Catalog Task(s) exist, which typically happens throughout the workflow, which is why I suggested adding the line in each Catalog Task activity, so that this is set when each Catalog Task is created. If you want to do it after the fact, you need to follow the GR format, and it's safer to you the request_item field to get the RITM, instead of the Parent which could be changed/set to something else.
var scTask = new GlideRecord('sc_task');
scTask.addQuery('request_item', current.sys_id);
scTask.query();
while (scTask.next()) {
scTask.watch_list=current.variables.watch_list;
scTask.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2022 12:14 PM
Hi Joe,
Map to field is only used for Record Producers. Out of the box, this field is hidden for Catalog Item variables. If you want the contents of this List Collector to be replicated on the RITM and/or SCTASK Watchlist, you would need to do this on the Workflow via a Run Script Activity, or you could create a Business Rule on the sc_req_item table before Insert to set your variable named watch_list to the field named watch_list. On the Advanced tab, your script will just be
(function executeRule(current, previous /*null when async*/) {
current.watch_list = current.variables.watch_list;
})(current, previous);
You can then do the same on the sc_task table with the Filter Condition Item is ... so that it only triggers for this Catalog Item, or you can do it in the workflow on the Catalog Task activity with a script:
task.watch_list = current.variables.watch_list;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 06:19 AM
Thanks Brad.
This is what I now have in a runscript in my workflow.
It's still not working:
var scTask = new GlideRecord('sc_task');
scTask.addQuery('parent', current.sys_id);
scTask.query();
scTask.watch_list=current.variables.watch_list;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 09:23 AM
A workflow Run Script runs on the sc_req_item table, so to set the RITM watch_list field the same as your watch_list variable, you would just need this line:
current.watch_list = current.variables.watch_list;
To set the watch_list field on Catalog Task(s), you can also include a GR to the sc_task table, but this must be done after the Catalog Task(s) exist, which typically happens throughout the workflow, which is why I suggested adding the line in each Catalog Task activity, so that this is set when each Catalog Task is created. If you want to do it after the fact, you need to follow the GR format, and it's safer to you the request_item field to get the RITM, instead of the Parent which could be changed/set to something else.
var scTask = new GlideRecord('sc_task');
scTask.addQuery('request_item', current.sys_id);
scTask.query();
while (scTask.next()) {
scTask.watch_list=current.variables.watch_list;
scTask.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2022 12:21 PM