- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2017 06:49 AM
We're needing to add the callers manager to the incident watch list, if the caller_id.u_cs_home_agent check flag is true. I've tried a few scripts that I've found on the community but cannot seem to get it working. Tried business rule on before and after. Tried with a condition and without.
current.caller_id.u_cs_home_agent == "true"
addToWatchList(); | |
function addToWatchList() { | |
current.watch_list += current.caller_id.manager;
var gr = new GlideRecord('sys_user'); | |
gr.addQuery('name',current.caller_id.manager); | |
gr.query(); | |
while(gr.next()) | |
{ | |
var user =(','+ gr.user); | |
current.watch_list += user; | |
} | |
} |
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2017 07:06 AM
HI Andrea,
It should be a before update business rule, and you can leave the condition in place but remove the apostrophes from "true" check as it validates the boolean value, rather than string,
try setting up the business rule like this and test if that works as expected in your case:
Condition:
current.caller_id.u_cs_home_agent == true && current.watch_list.indexOf(current.caller_id.manager) == -1
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if (current.watch_list == ''){
current.watch_list += current.caller_id.manager;
} else {
current.watch_list += ',' + current.caller_id.manager;
}
})(current, previous);
Please let me know if this solves your issue.
Best regards,
A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2017 07:06 AM
HI Andrea,
It should be a before update business rule, and you can leave the condition in place but remove the apostrophes from "true" check as it validates the boolean value, rather than string,
try setting up the business rule like this and test if that works as expected in your case:
Condition:
current.caller_id.u_cs_home_agent == true && current.watch_list.indexOf(current.caller_id.manager) == -1
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if (current.watch_list == ''){
current.watch_list += current.caller_id.manager;
} else {
current.watch_list += ',' + current.caller_id.manager;
}
})(current, previous);
Please let me know if this solves your issue.
Best regards,
A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2017 07:45 AM
Hello Andras,
Thank you so much for the quick reply. It's working...:)))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2017 03:16 PM
HI Andrea,
In the meantime I realized that some more scripting and conditions needs to be added to your business rule to ensure it works and adds caller manager to the watch list properly, especially if the incident is getting updated multiple times.
You should use the updated business rule below:
Condition:
current.caller_id.u_cs_home_agent == true && current.watch_list.indexOf(current.caller_id.manager) == -1
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if (current.watch_list == ''){
current.watch_list += current.caller_id.manager;
} else {
current.watch_list += ',' + current.caller_id.manager;
}
})(current, previous);
Best regards,
A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2017 05:13 AM
Hello Andras,
I've changed the business rule and everything works great...Thanks again..:)