How can we set Watchlist Users of Catalog Task from Service Catalog Item Variable automatically?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 08:04 PM
How can we set Watchlist of Catalog Task from Service Catalog Item Variable automatically?
As when we set while updating Watchlist Users of Catalog Task from Service Catalog Item Variable having list of Users which is list collector field in Flow Designer it does not happen.
Please guide on the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 08:31 PM
You can refer to this article by Ankur https://www.servicenow.com/community/developer-blog/using-list-collector-in-flow-designer-for-each-l... and store your watchlist users in an array and then update watchlist in catalog tasks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 09:49 PM
HI @VIKAS45 ,
I trust you are doing great.
To address this issue, you can use a Script Step in Flow Designer to manually update the Watchlist of the Catalog Task. Here's an example code snippet that demonstrates how you can achieve this:
(function execute(inputs, outputs) {
var taskID = inputs.task.sys_id;
var userList = inputs.item.variableName;
var taskGR = new GlideRecord('sc_task');
if (taskGR.get(taskID)) {
taskGR.watch_list = userList;
taskGR.update();
}
})(inputs, outputs);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 02:58 AM - edited 05-16-2023 03:11 AM
Hi Amit,
Where Should I write this script in
1)ISubFlow Input and Output
2)In Setting Flow Variables with script
3) Updating Catalog Task Watch_list field with script
4)Action Module in Servicenow
Also what should we select variable Type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 10:49 PM
- Watchlist Users can be set from the Service Catalog Item Variable by creating a business rule on the sc_task table
- The business rule should be a "Before Insert" type -The script should use the current.variables.watchlist_users to get the value of the variable
- The script should set the value of the watchlist_users field to the value of the variable
- The business rule should be activated to take effect
For asking ServiceNow-related questions try this :
For a good and optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/