REQ/RITM/TASK watch list

Brendan Hallida
Kilo Guru

Hi all,

I have a Business rule which updates the request and request item watch list whenever the watch list for the catalog task is changed.   This includes removing users from the watch list.

Table: sc_task

When to run: Before, Insert, Update

(function() {

  //get the gliderecord for the parent request

  var req = new GlideRecord('sc_request');

  if (req.get(current.request)) {

          req.watch_list = current.watch_list;

    req.update();

  }

  //get the gliderecord for the parent request item

  var reqitem = new GlideRecord('sc_req_item');

  if (reqitem.get(current.request_item)) {

          reqitem.watch_list = current.watch_list;

    reqitem.update();

  }

})();

This works great for single REQ/RITM/Tasks (which is all we have at the moment) however I can see the need for multiple tasks coming in the not too distant future, and would like to plan for that with any scripts i may be placing into the environment.

Does anyone know how I could approach this with the business rule above?

Cheers,

Brendan

1 ACCEPTED SOLUTION

Brendan Hallida
Kilo Guru

Hi all,



I ended up going with using the request watch list on the catalog task form, and using the request watch list for all the notifications.



To get the request watch list onto the task form working properly, I needed to use parent.parent.watchlist, however I needed to create a BR that sets the REQ as the RITM's parent.   Sometimes they don't make it easy.



REQ RITM parent relationship


View solution in original post

8 REPLIES 8

YOu have to write this above code of manoj in both queries.....1 to update sc_request and 2nd for sc_re_item


Manoj Kumar16
Giga Guru

Yes add the code to your existing code that will update all your tasks. If you have more than 1 RITM under 1 request then add a business rule on sc_req_item table to update all the RITMs under the current request.


Brendan Hallida
Kilo Guru

Hi all,



I ended up going with using the request watch list on the catalog task form, and using the request watch list for all the notifications.



To get the request watch list onto the task form working properly, I needed to use parent.parent.watchlist, however I needed to create a BR that sets the REQ as the RITM's parent.   Sometimes they don't make it easy.



REQ RITM parent relationship


Jackie23
Kilo Guru

I was able to use the code you did in your first post, and it work correct. But when a new task is created it wipes out my existing watchlist. Were you able to resolve this issue or do you know how I can do that on my end? 

 

Jackie23_0-1689274740690.png

 

Thanks, 

Jackie