- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2022 12:03 AM
Hi Team,
How to glide through case table from current case record to check other case records if they have same account in account field and active escalation field is empty or not in those records and if active escalation field is empty in all cases which has same account set the customm true/false field (u_escalation) which is on account table to false. if active escalation field is NOT empty in any one of the cases for same account set the 'u_escalation' field to true.
I wrote the after update Business rule to try to acheive it but it is working for single case update. it is not querying the case table to check other records which have same account.
Please fix my script to acheive my goal.
Here is my Script.
(function executeRule(current, previous /*null when async*/ ) {
if (current.active_escalation == "") {
var vam = new GlideRecord('customer_account');
vam.addQuery('sys_id', current.account);
vam.query();
if (vam.next()) {
// Here i need help to add query other case records which has same account and to check if any record in those having any Active escalation then let the u_escalations is true state. if no record has the active esscalation change the u_escalation to False.
vam.u_escalations = "false";
vam.update();// to update to false
}
} else {
var vam1 = new GlideRecord('customer_account');
vam1.addQuery('sys_id', current.account);
vam1.query();
if (vam1.next()) {
vam1.u_escalations = "true";
vam1.update();// to update to true.
}
}
})(current, previous);
Thanks in advance,
Hari Kishan.
Solved! Go to Solution.
- Labels:
-
Customer Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2022 02:19 AM
Hi Anil,
Firstly thanks for the modification.
i did made some modifications after Line 12 and added below lines.
if (caseGr.hasNext()){
vam.u_escalations = "true";
vam.update();// Still Stays in True state
} else {
vam.u_escalations = "false";
vam.update(); // update to false
}}
Then it worked as expected to my need.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2022 12:45 AM
Hi,
Please check if below logic works for you.
(function executeRule(current, previous /*null when async*/ ) {
if (current.active_escalation == "") {
var vam = new GlideRecord('customer_account');
vam.addQuery('sys_id', current.account);
vam.query();
if (vam.next()) {
// Here i need help to add query other case records which has same account and to check if any record in those having any Active escalation then let the u_escalations is true state. if no record has the active esscalation change the u_escalation to False.
var caseGr = new GlideRecord('sn_customerservice_case');
caseGr.addQuery('account', current.account.toString());
caseGr.addEncodedQuery('active_escalationISNOTEMPTY');
caseGr.query();
if (caseGr.hasNext()) {
vam.u_escalations = "false";
vam.update(); // to update to false
}
}
} else {
var vam1 = new GlideRecord('customer_account');
vam1.addQuery('sys_id', current.account);
vam1.query();
if (vam1.next()) {
vam1.u_escalations = "true";
vam1.update(); // to update to true.
}
}
})(current, previous);
Note I have updated script as per my understanding. Please make required/minor changes if needed. I hope you will get above logic.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2022 02:19 AM
Hi Anil,
Firstly thanks for the modification.
i did made some modifications after Line 12 and added below lines.
if (caseGr.hasNext()){
vam.u_escalations = "true";
vam.update();// Still Stays in True state
} else {
vam.u_escalations = "false";
vam.update(); // update to false
}}
Then it worked as expected to my need.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2022 02:39 AM
Glad to know your issue is resolved. I believe you were needed logic to find escalation related with account which I provided and suggested you to make required changes as per your requirement.
Looks like you marked your own answer as correct, please mark correct response as correct so that others can refer solution in future.
Thanks,
Anil Lande
Thanks
Anil Lande