
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2020 01:17 PM
I am trying to build an inbound email flow designer. What I need to be able to do is add a group of users to the watchlist on the incident form. What I tried to do originally was do a lookup of the group and then do a for each item and assign that to a variable. I cannot find a way to assign the values to a variable recursively so that they become a comma separated list. So then I tried to build a sub flow and assign the values to the output variable, but it doesn't allow you to attach the values in a list to the output variable. Any help is much appreciated.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2020 02:33 AM
HI,
I have created a custom action which can be used in all tables as below:
1) Inputs:
Group Name : name of group so that users for this group can go to watchlist
Table Name: Table name
Table Sys Id: Where the watch list has to be updated.
2) Script:
(function execute(inputs, outputs) {
// ... code ...
var inc = new GlideRecord(inputs.tableName);
inc.addQuery('sys_id',inputs.tableSysId);
inc.addActiveQuery();
inc.query();
if(inc.next()){
var arr = [];
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('group.name',inputs.groupname);
grp.query();
while(grp.next()){
arr.push(grp.user+'');
}
inc.watch_list = arr.toString();
inc.update();
}
outputs.ids = arr.toString();
})(inputs, outputs);
3) Outputs:
Tested Result:
Attached is the xml of the Action:
Thnks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2020 01:58 PM
You can configure script step to add users to watch list in your flow.
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2020 01:38 AM
HI,
The group is always common or it is dynamic?
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2020 02:33 AM
HI,
I have created a custom action which can be used in all tables as below:
1) Inputs:
Group Name : name of group so that users for this group can go to watchlist
Table Name: Table name
Table Sys Id: Where the watch list has to be updated.
2) Script:
(function execute(inputs, outputs) {
// ... code ...
var inc = new GlideRecord(inputs.tableName);
inc.addQuery('sys_id',inputs.tableSysId);
inc.addActiveQuery();
inc.query();
if(inc.next()){
var arr = [];
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('group.name',inputs.groupname);
grp.query();
while(grp.next()){
arr.push(grp.user+'');
}
inc.watch_list = arr.toString();
inc.update();
}
outputs.ids = arr.toString();
})(inputs, outputs);
3) Outputs:
Tested Result:
Attached is the xml of the Action:
Thnks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2020 05:33 AM
This is awesome Ashutosh! Thank you so much! I'm kinda new to ServiceNow coding and I thought it should have gone into a Subflow. I hadn't tried it in an Action yet.