How do I add a watchlist to a Requested Item?

Joe Taylor
Giga Guru

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.

 

JoeTaylor_0-1668020506150.png

 

 

 

1 ACCEPTED SOLUTION

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();
}

View solution in original post

4 REPLIES 4

Brad Bowman
Kilo Patron
Kilo Patron

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;

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;

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();
}

Asma Yousaf
Tera Contributor

Hi,

if you want to map the field then first you have to select the table name from which table you want to map the field...