
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2017 01:46 PM
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
addToWatchList();
function addToWatchList() {
if(current.assignment_group.getDisplayValue() == 'Finance Support') {
current.watch_list == 'Joe Smith';
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2017 02:35 PM
*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.
Your business rule should also be wrapped in an executeRule function which should be automatically generated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2017 05:38 PM
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?
Thanks
Julio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2017 06:37 PM
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:
- All before business rules that run on a record insert with an order value less than 1000.
- The first assignment rule with the lowest execution order and matching condition.
- All before business rules that run on a record insert with an order value greater than or equal to 1000.
- 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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2017 09:32 AM
Thanks that was the issue. I changed the order of my BR to 1001 and everything worked correctly.
-Julio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2017 01:54 AM
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
Regards,
Shloke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2017 09:33 AM
Thanks this one also worked.
-Julio