- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2016 09:02 AM
Hi All,
We have a scenario where some of our app owners are going to need to be aware of incidents. They don't work the incidents so we don't want to assign them and consume a license. We do need to give them access to view the incidents that come in about their area though.
When I select a configuration item, the Owner and Support group are also shown on my form. Based on the Configuration Item selected on the incident, I'd like to add the Owner and Support Group members to the watch list.
Can anyone help me with a script to add a group's members to the watchlist of an incident on insert or maybe when a Boolean field is set to true?
Thanks,
Carl
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2016 09:25 AM
You could create a business rule that adds the owner and group members to the watch list when the incident is created and the values are present on the CI. Haven't tested this specifically, but something similar has worked for me.
Create new business rule: Add CI Owner to watch list
Table: Incident [incident]
When: before
Insert: True
Script:
//Add opened by to the watch list on the requested item if different from the requested for
addToWatchList();
function addToWatchList() {
//get CI owner and ad to watch list
current.watch_list += current.cmdb_ci.owner;
//get group members
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group',current.cmdb_ci.support_group);
gr.query();
while(gr.next())
{
var user =(','+ gr.user);
current.watch_list += user;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016 11:39 AM
Sorry I thought I'd sent this reply.
We were able to figure out that we had the wrong field name
it's CMDB_CI.Owned_By not .Owner
So you got it right but I gave the wrong field or didn't pay attention.
Thanks so much. This has been very helpful!!!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016 11:41 AM
Awesome! Thanks for the update.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2017 01:50 PM
Hello,
We've been using this script for a while now and it works but it's adding the owner and group every time the record is updated.
I only need them added to the watchlist once. Is there something I can do to avoid this?
Thanks in advance.
Carl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2017 01:58 PM
We have it set before insert, so it won't try to re-add them again on update. Are you running this on before update as well as insert? Pretty sure you could script a check to see if they are already in the watch list and add if not, otherwise skip.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2017 02:09 PM
Thanks for replying. Yes I have this on insert and update.
On Insert, if contact type is phone, it would be on submit but if it came in via self service, it would need to be properly categorized first in which case it would be on update.
I have attached screenshots of the script I am using incase something got changed.