Auto add user to watchlist

juliochacon23
Tera Expert

Hi, I am trying to setup a business rule to auto add a user (Joe Smith) to a watchlist when the incident is assigned to the certain assignment group.   This is what I have but it is not working.   Also this should append the user not remove any existing users to the watchlist.

Any help much appreciated.   Thanks

-Julio

find_real_file.png

addToWatchList();

function addToWatchList() {

if(current.assignment_group.getDisplayValue() == 'Finance Support') {

  current.watch_list == 'Joe Smith';

}

}

find_real_file.png

1 ACCEPTED SOLUTION

andrewpilachows
Kilo Guru

*Have to research



"==" is comparison, "=" is assignment, and "+=" is a shorthand for append.   You need to check if watch_list is empty before doing an append or an assignment though.   In order to not be hardcoding "Joe", use a system property (sys_properties.list).   This will allow you to quickly change it without having to go back and update a script and push the set through testing.   Say the name of the property is "incident.auto_watch" as a string value.



var watchers = gs.getProperty('incident.auto_watch');


if (current.watch_list.nil())


    current.watch_list = watchers;


else


    current.watch_list += ',' + watchers;



Use the filter function to select assignment group instead of the script.


find_real_file.png



Your business rule should also be wrapped in an executeRule function which should be automatically generated.


find_real_file.png


View solution in original post

9 REPLIES 9

Thanks for the help but I seem to be having an issue when the ticket is created using the self service portal.   If I remove the condition from the business rule to any incident not just the one assinged to the assignment group then the BR works.   The user gets added to the watchlist, but our users use the self service portal to create tickets.   I have assignement rules that assigns incidents to certain assignment groups.   There seems to an an issue in timing when the assignmen rule kicks in and then the BR rule.   I tried adding the code to the assignment rule instread of the business rule but it does not seem to work.   Any ideas?



find_real_file.png


find_real_file.png



find_real_file.png



Thanks


Julio


1.2.1 Precedence between Assignment Rules and Business Rules

When creating new assignment rules, keep in mind that business rules can take precedence over assignment rules in certain circumstances. Assignment rules and business rules run in the following order:


  1. All before business rules that run on a record insert with an order value less than 1000.
  2. The first assignment rule with the lowest execution order and matching condition.
  3. All before business rules that run on a record insert with an order value greater than or equal to 1000.
  4. All after business rules that run on record insert.


You can use a BR, just have to set the order to 1000, and make sure its a before insert and update.



Just realized I had a typo, append should be


current.watch_list += ',' + watchers;



Did you create the system property incident.auto_watch?   The value should be Joe's sys_id.


find_real_file.png


Thanks that was the issue.   I changed the order of my BR to 1001 and everything worked correctly.



-Julio


Yeah it can be done. You simply need to select both Insert & Update Checkbox on the Business Rule form. Currently the script which I provided was on Update only.


Update it to both and this will Resolve your issue.



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Thanks this one also worked.



-Julio