Escalate an Account

Prakash_S
Tera Contributor

if all case of an account have been escalated then respective account should get auto escalate

2 ACCEPTED SOLUTIONS

Runjay Patel
Giga Sage

Hi @Prakash_S ,

 

You can create after BR on case table and use below script.

 var accountId = current.account;
        if (accountId) {
            // Query all active cases of the account
            var caseGR = new GlideRecord('sn_customerservice_case');
            caseGR.addEncodedQuery('active_escalationISNOTEMPTY^account=' + accountId + '^active=true');
            caseGR.query();

            var allEscalated = true;
            if (caseGR.next()) {
                allEscalated = false;

            }

            // If all cases are escalated, escalate the account
            if (allEscalated) {
                var accountEscGR = new GlideRecord('sn_customerservice_escalation');
                accountEscGR.initialize();
                accountEscGR.source_record = accountId;
                accountEscGR.request_source = 1;
                accountEscGR.insert();
            }
        }

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

View solution in original post

Here in this Video, I have covered the Custom Application Pattern Troubleshooting and configuration Thank you for visiting my channel. Here, I'll share various technical knowledge. Feel free to reach out to me directly for any Service Now-related queries. Your support encourages me to consistently

Ankur Bawiskar
Tera Patron

@Prakash_S 

you can use flow designer for this with no-code design

OR

use after update BR on Case table with below script

Condition: Active Escalation Changes and Active Escalation IS NOT EMPTY

var caseGR = new GlideRecord('sn_customerservice_case');
caseGR.addQuery('account', current.account);
caseGR.addEncodedQuery('active_escalationISNOTEMPTY');
caseGR.query();
if (!caseGR.hasNext()) {
    // All cases are escalated, escalate the account
    var escalationGr = new GlideRecord('sn_customerservice_escalation');
    escalationGr.initialize();
    escalationGr.source_record = current.account;
	escalationGr.source_table = 'customer_account';
    escalationGr.request_source = 0;
    escalationGr.insert();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Runjay Patel
Giga Sage

Hi @Prakash_S ,

 

You can create after BR on case table and use below script.

 var accountId = current.account;
        if (accountId) {
            // Query all active cases of the account
            var caseGR = new GlideRecord('sn_customerservice_case');
            caseGR.addEncodedQuery('active_escalationISNOTEMPTY^account=' + accountId + '^active=true');
            caseGR.query();

            var allEscalated = true;
            if (caseGR.next()) {
                allEscalated = false;

            }

            // If all cases are escalated, escalate the account
            if (allEscalated) {
                var accountEscGR = new GlideRecord('sn_customerservice_escalation');
                accountEscGR.initialize();
                accountEscGR.source_record = accountId;
                accountEscGR.request_source = 1;
                accountEscGR.insert();
            }
        }

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Here in this Video, I have covered the Custom Application Pattern Troubleshooting and configuration Thank you for visiting my channel. Here, I'll share various technical knowledge. Feel free to reach out to me directly for any Service Now-related queries. Your support encourages me to consistently

Ankur Bawiskar
Tera Patron

@Prakash_S 

you can use flow designer for this with no-code design

OR

use after update BR on Case table with below script

Condition: Active Escalation Changes and Active Escalation IS NOT EMPTY

var caseGR = new GlideRecord('sn_customerservice_case');
caseGR.addQuery('account', current.account);
caseGR.addEncodedQuery('active_escalationISNOTEMPTY');
caseGR.query();
if (!caseGR.hasNext()) {
    // All cases are escalated, escalate the account
    var escalationGr = new GlideRecord('sn_customerservice_escalation');
    escalationGr.initialize();
    escalationGr.source_record = current.account;
	escalationGr.source_table = 'customer_account';
    escalationGr.request_source = 0;
    escalationGr.insert();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader