---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# OnCallEscalationTemplateSNC - Global

# OnCallEscalationTemplateSNC - Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read

The OnCallEscalationTemplateSNC script include provides methods to apply escalation policy templates to escalation sets.

For more information about the escalation process, see [Defining On-Call Scheduling escalation process](https://www.servicenow.com/docs/access?context=defining-escalation-process-and-template&version=xanadu&pubname=xanadu-it-service-management&ft:locale=en-US).

This script include requires the On-Call Scheduling plugin (com.snc.on_call_rotation).

## OnCallEscalationTemplateSNC - OnCallEscalationTemplateSNC() {#ariaid-title2}

Instantiates an OnCallEscalationTemplateSNC object.
{#OnCallEscTemp-OnCallEscTemp__table_y2b_lld_rxb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#OnCallEscTemp-OnCallEscTemp__table_y2b_lld_rxb}  
This example instantiates an OnCallEscalationTemplateSNC object.

    var escTemp = new global.OnCallEscalationTemplateSNC();

## OnCallEscalationTemplateSNC - copyEscalationTemplatetoEscalationSet(String templateSysId, String escalationSetSysId) {#ariaid-title3}

Applies an escalation policy template to an escalation set.
When the template is applied to the escalation set, escalation step definition records are created in the Shift Escalation Step Definition \[cmn_rota_esc_step_def\] table.

Before calling this method, call the deleteEscalationSetSteps() method to delete existing escalation step definitions. If existing records are not deleted first, this method returns an error.
{#OnCallEscTemp-copyEsTempEsSet_S_S__table_wh5_3td_3xb__entry__3}

| Name | Type | Description |
|-|-|-|
| templateSysId | String | Sys_id of the escalation policy template in the On-Call Escalation Policy Template \[on_call_template_escalation_policy\] table. |
| escalationSetSysId | String | Sys_id of the escalation set in the Shift Escalation Set \[cmn_rota_escalation_set\] table. |
[Table 2. Parameters]

{#OnCallEscTemp-copyEsTempEsSet_S_S__table_wh5_3td_3xb} {#OnCallEscTemp-copyEsTempEsSet_S_S__table_xh5_3td_3xb__entry__2}

| Type | Description |
|-|-|
| Object | Object containing error and warning messages. If the operation was successful, this object is empty. Note: If an error occurs, the operation stops and the template is not applied. If a warning occurs, the operation continues and some records are still created. { "error": "String", "warning": {Object} } |
| \<Object\>.error | Error message. Possible errors: * Escalation policy template sys_id is not correct. * Escalation set sys_id is not correct. * Escalation step definitions already exist on escalation set. {#OnCallEscTemp-copyEsTempEsSet_S_S__ul_dmh_3tc_kxb} Data type: String |
| \<Object\>.warning | Information about any warnings. Data type: Object { "message": "String", "skipped_steps": [Array], "not_matching_steps": {Object}, } |
| \<Object\>.warning.message | Warning message. Possible warnings: * Roster position does not match the rosters on the shift * There are no audiences defined on the escalation step template {#OnCallEscTemp-copyEsTempEsSet_S_S__ul_zwt_zhr_rxb} Data type: String |
| \<Object\>.warning.skipped_steps | Indexes of any escalation steps that were skipped (1-based). Data type: Array |
| \<Object\>.warning.not_matching_steps | Object containing information about any escalation steps that do not have available rosters in the format `{"step number":[roster number]}`. For example, if the return value is `{"3":[3]}`, then at escalation step three the tertiary roster is not available. Data type: Object |
[Table 3. Returns]

{#OnCallEscTemp-copyEsTempEsSet_S_S__table_xh5_3td_3xb}  
This example applies the Rotate through rosters escalation policy template to the Service Desk -- Default escalation set. The return object is empty because there are no errors or warnings.

    var escSetSysId = "32820dc3eb422110249e8d835d5228c3";
    var templateSysId = "a89e2982eb592110249e8d835d522825";
    var escTemp = new global.OnCallEscalationTemplateSNC();

    // delete existing escalation step definitions before applying the template
    escTemp.deleteEscalationSetSteps(escSetSysId);

    var result = escTemp.copyEscalationTemplatetoEscalationSet(templateSysId, escSetSysId);
    gs.info(JSON.stringify(result));

Output:

    {}

This example applies the Rotate through roster escalation policy template to the Working Hours -- Default escalation set. In this case, the Application Development shift has only two rosters but the template tries to assign a third
roster. Since the number of rosters doesn't match, a warning is thrown. Two records are still created in the Shift Escalation Step Definition \[cmn_rota_esc_step_def\] table.

    var escSetSysId = "e4f8f73deb562110249e8d835d522852";
    var templateSysId = "a89e2982eb592110249e8d835d522825";
    var escTemp = new global.OnCallEscalationTemplateSNC();

    // delete existing escalation step definitions before applying the template
    escTemp.deleteEscalationSetSteps(escSetSysId);

    var result = escTemp.copyEscalationTemplatetoEscalationSet(templateSysId, escSetSysId);
    gs.info(JSON.stringify(result));

Output:

    {
       "warning": {
          "message": "Skipped copying templates for some of the steps since no audiences are defined",
          "not_matching_steps": {
             "3": [
                3
             ]
          },
          "skipped_steps": [
             "3"
          ]
       }
    }

## OnCallEscalationTemplateSNC - deleteEscalationSetSteps(String escalationSetSysId) {#ariaid-title4}

Deletes all escalation step definition records associated with an escalation set.
{#OnCallEscTemp-deleteEsSetSteps_S__table_rvx_35d_3xb__entry__3}

| Name | Type | Description |
|-|-|-|
| escalationSetSysId | String | Sys_id of the escalation set in the Shift Escalation Set \[cmn_rota_escalation_set\] table. |
[Table 4. Parameters]

{#OnCallEscTemp-deleteEsSetSteps_S__table_rvx_35d_3xb} {#OnCallEscTemp-deleteEsSetSteps_S__table_svx_35d_3xb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 5. Returns]

{#OnCallEscTemp-deleteEsSetSteps_S__table_svx_35d_3xb}  
This example deletes all escalation step definitions associated with the Service Desk -- Default escalation set.

    var escSetSysId = "32820dc3eb422110249e8d835d5228c3";

    var escTemp = new global.OnCallEscalationTemplateSNC();

    escTemp.deleteEscalationSetSteps(escSetSysId);


