{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":859,"path":"api-reference/server-api-reference/OnCallEscalationTemplateSNCAPI.md","title":"OnCallEscalationTemplateSNC - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# OnCallEscalationTemplateSNC- Global\n\nThe OnCallEscalationTemplateSNC script include provides methods to apply escalation policy templates to escalation sets.\n\nFor more information about the escalation process, see [Defining On-Call Scheduling escalation process](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/it-service-management/defining-escalation-process-and-template.md).\n\nThis script include requires the On-Call Scheduling plugin \\(com.snc.on\\_call\\_rotation\\).\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## OnCallEscalationTemplateSNC - OnCallEscalationTemplateSNC\\(\\)\n\nInstantiates an OnCallEscalationTemplateSNC object.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| ||\n\nThis example instantiates an OnCallEscalationTemplateSNC object.\n\n```\nvar escTemp = new global.OnCallEscalationTemplateSNC();\n```\n\n## OnCallEscalationTemplateSNC - copyEscalationTemplatetoEscalationSet\\(String templateSysId, String escalationSetSysId\\)\n\nApplies an escalation policy template to an escalation set.\n\nWhen 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.\n\nBefore 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.\n\n|Name|Type|Description|\n|----|----|-----------|\n|templateSysId|String|Sys\\_id of the escalation policy template in the On-Call Escalation Policy Template \\[on\\_call\\_template\\_escalation\\_policy\\] table.|\n|escalationSetSysId|String|Sys\\_id of the escalation set in the Shift Escalation Set \\[cmn\\_rota\\_escalation\\_set\\] table.|\n\n<table id=\"table_xh5_3td_3xb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nObject\n\n</td><td>\n\nObject containing error and warning messages. If the operation was successful, this object is empty.\n\n**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.\n\n ```\n{\n  \"error\": \"String\", \n  \"warning\": {Object} \n}\n```\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.error\n\n</td><td>\n\nError message.Possible errors:\n\n-   Escalation policy template sys\\_id is not correct.\n-   Escalation set sys\\_id is not correct.\n-   Escalation step definitions already exist on escalation set.\n\nData type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.warning\n\n</td><td>\n\nInformation about any warnings.Data type: Object\n\n```\n{\n  \"message\": \"String\", \n  \"skipped_steps\": [Array],\n  \"not_matching_steps\": {Object},\n}\n```\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.warning.message\n\n</td><td>\n\nWarning message.Possible warnings:\n\n-   Roster position does not match the rosters on the shift\n-   There are no audiences defined on the escalation step template\n\nData type: String\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.warning.skipped\\_steps\n\n</td><td>\n\nIndexes of any escalation steps that were skipped \\(1-based\\).Data type: Array\n\n</td></tr><tr><td>\n\n&lt;Object&gt;.warning.not\\_matching\\_steps\n\n</td><td>\n\nObject 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.\n\nData type: Object\n\n</td></tr></tbody>\n</table>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.\n\n```\nvar escSetSysId = \"32820dc3eb422110249e8d835d5228c3\";\nvar templateSysId = \"a89e2982eb592110249e8d835d522825\";\nvar escTemp = new global.OnCallEscalationTemplateSNC();\n\n// delete existing escalation step definitions before applying the template\nescTemp.deleteEscalationSetSteps(escSetSysId);\n\nvar result = escTemp.copyEscalationTemplatetoEscalationSet(templateSysId, escSetSysId);\ngs.info(JSON.stringify(result));\n```\n\nOutput:\n\n```\n{}\n```\n\nThis 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.\n\n```\nvar escSetSysId = \"e4f8f73deb562110249e8d835d522852\";\nvar templateSysId = \"a89e2982eb592110249e8d835d522825\";\nvar escTemp = new global.OnCallEscalationTemplateSNC();\n\n// delete existing escalation step definitions before applying the template\nescTemp.deleteEscalationSetSteps(escSetSysId);\n\nvar result = escTemp.copyEscalationTemplatetoEscalationSet(templateSysId, escSetSysId);\ngs.info(JSON.stringify(result));\n```\n\nOutput:\n\n```\n{\n   \"warning\": {\n      \"message\": \"Skipped copying templates for some of the steps since no audiences are defined\",\n      \"not_matching_steps\": {\n         \"3\": [\n            3\n         ]\n      },\n      \"skipped_steps\": [\n         \"3\"\n      ]\n   }\n}\n```\n\n## OnCallEscalationTemplateSNC - deleteEscalationSetSteps\\(String escalationSetSysId\\)\n\nDeletes all escalation step definition records associated with an escalation set.\n\n|Name|Type|Description|\n|----|----|-----------|\n|escalationSetSysId|String|Sys\\_id of the escalation set in the Shift Escalation Set \\[cmn\\_rota\\_escalation\\_set\\] table.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThis example deletes all escalation step definitions associated with the Service Desk – Default escalation set.\n\n```\nvar escSetSysId = \"32820dc3eb422110249e8d835d5228c3\";\n\nvar escTemp = new global.OnCallEscalationTemplateSNC();\n\nescTemp.deleteEscalationSetSteps(escSetSysId);\n```\n\n"}}