---
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


---

# OnCallContactPrefTemplate - Global

# OnCallContactPrefTemplate - Global {#ariaid-title1}

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

The OnCallContactPrefTemplate script include provides methods to apply contact preference 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).

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

Instantiates an OnCallContactPrefTemplate object.
{#OnCallCtPrefTemp-OnCallCtPrefTemp__table_b1n_q5c_kxb__entry__3}

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

{#OnCallCtPrefTemp-OnCallCtPrefTemp__table_b1n_q5c_kxb}  
This example instantiates an OnCallContactPrefTemplate object.

    var contactPrefTemp = new global.OnCallContactPrefTemplate();

## OnCallContactPrefTemplate - copyContactPreferences(String templateSysId, String escalationSetSysId) {#ariaid-title3}

Applies a contact preference template to an escalation set.
When the template is applied to the escalation set, contact attempt records are created in the Shift Contact Preference \[cmn_rota_contact_preference\] table.

Before calling this method, call the deleteContactPreferenceAttempts() method to delete existing contact attempt records. If existing records are not deleted first, this method returns an error.
{#OnCallCtPrefTemp-copyCtPrefs_S_S__table_cgl_2rd_3xb__entry__3}

| Name | Type | Description |
|-|-|-|
| templateSysId | String | Sys_id of the contact preference template in the On-Call Contact Preference Template \[on_call_template_contact_preference\] table. |
| escalationSetSysId | String | Sys_id of the escalation set in the Shift Escalation Set \[cmn_rota_escalation_set\] table. |
[Table 2. Parameters]

{#OnCallCtPrefTemp-copyCtPrefs_S_S__table_cgl_2rd_3xb} {#OnCallCtPrefTemp-copyCtPrefs_S_S__table_dgl_2rd_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": "String" } |
| \<Object\>.error | Error message. Possible values: * Contact preference template sys_id is not correct * Escalation set sys_id is not correct * Contact attempts exist already {#OnCallCtPrefTemp-copyCtPrefs_S_S__ul_dmh_3tc_kxb} Data type: String |
| \<Object\>.warning | Warning message. Data type: String |
[Table 3. Returns]

{#OnCallCtPrefTemp-copyCtPrefs_S_S__table_dgl_2rd_3xb}  
This example applies a contact preference template to the Service Desk -- Default escalation set. The return object is empty because there are no errors or warnings.

    var escSetSysId = "a47ac1abeb5a6110249e8d835d5228aa";
    var templateSysId = "f8dac9ebeb5a6110249e8d835d522873";

    var contactPrefTemp = new global.OnCallContactPrefTemplate();

    // delete existing contact attempt records before applying the template
    contactPrefTemp.deleteContactPreferenceAttempts(escSetSysId); 

    var result = contactPrefTemp.copyContactPreferences(templateSysId, escSetSysId);
    gs.info(JSON.stringify(result));

Output:

    {}

## OnCallContactPrefTemplate - deleteContactPreferenceAttempts(String escalationSetSysId) {#ariaid-title4}

Deletes all contact preferences associated with an escalation set.
All contact attempt records for the escalation set are deleted from the Shift Contact Preference \[cmn_rota_contact_preference\] table.
{#OnCallCtPrefTemp-deleteCtPrefAtt_S__table_zlg_zqd_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]

{#OnCallCtPrefTemp-deleteCtPrefAtt_S__table_zlg_zqd_3xb} {#OnCallCtPrefTemp-deleteCtPrefAtt_S__table_amg_zqd_3xb__entry__2}

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

{#OnCallCtPrefTemp-deleteCtPrefAtt_S__table_amg_zqd_3xb}  
This example deletes all contact preferences associated with the Service Desk -- Default escalation set.

    var escSetSysId = "a47ac1abeb5a6110249e8d835d5228aa";
    var contactPrefTemp = new global.OnCallContactPrefTemplate();

    contactPrefTemp.deleteContactPreferenceAttempts(escSetSysId);


