- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2020 07:03 AM
Hi Friends,
Please help me with my below requirement.
I have a list collector variable xyz in abc variable set. This variable refers sys_user table.
how can we map the users in xyz variable to watch_list field on RITM notes section (after submitting the request).
I guess we can create catelog client script on variable set and get the value of xyz variable and send to script include and then there we can map these value with watchlist.
I am unable to implement the code, so could someone please help me with the code.
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2020 08:10 AM
Thanks for the update Kumaraj. No worries. Below, please find the solution that I shared with you.
Create a Before business rule with Script as:
current.watch_list = current.variables.xyz;
Let me know if that answered your question. If so, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2020 02:01 AM
Hi Ankur, Thank you very much for quick reply,
you got me right, so could you please suggest me how to proceed with BR, if you can help me with steps and code then really thankful to you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2020 02:46 AM
Hi Kumaraj,
Please follow steps below.
1. Navigate to System Definition-> Business Rule
2. Click on New button
3. Input the name field, select Table as sc_req_item, advanced checkbox value to true
4.Under when to run section select When to Before with insert checkbox value set to true
5.Under Avanced tab update the script as. Assuming the variable name is xyz.
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
current.watch_list = current.variables.xyz;
})(current, previous);
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2020 05:01 AM
Hi Pradip,
Thank you for your help,
By mistake I have deleted your response, so if in case you see then Thank you for your solution.
You made it simple and yes it is working now.
I just created a Before insert business rule and mapped the variable with watch_list.
Thanks you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2020 08:10 AM
Thanks for the update Kumaraj. No worries. Below, please find the solution that I shared with you.
Create a Before business rule with Script as:
current.watch_list = current.variables.xyz;
Let me know if that answered your question. If so, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2020 11:27 PM
Hi Kumar,
one drawback of the script if you use directly in BR would be
1) it would only work if the list collector variable is named as 'xyz' in all catalog items
2) if in some other catalog item the list collector variable name is 'abc' then the script would fail
So please check approach mentioned in my previous comment. it would take into account the above conditions
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
