Add CI SupportGroup to the watchlist automatically when a CI is selected

carlh
Kilo Guru

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

1 ACCEPTED SOLUTION

curtisr
Kilo Expert

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;


      }


}


View solution in original post

10 REPLIES 10