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


---

# PreferenceDestination - Scoped, Global

# PreferenceDestination - Scoped, Global {#ariaid-title1}

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

The PreferenceDestination API updates user notification
preferences.

A notification destination is somewhere that a notification can
be delivered to, such as a specific email address or phone number. This API is based on
notifications from the Notification \[sys_notification\] table. Notifications are sent through
channels such as email or Workspace. A channel can be used to send
notifications to multiple types of destinations. For example, an email channel could send
notifications to both personal email and work email destinations. Destination types are
listed in the Notification Destination Type \[sys_notif_destination_type\] table.

A user can update their own notification preferences, and an admin can update notification
preferences for any user. User notification preferences control which destinations will
receive which notifications.

Use this API with the [Preferences](https://servicenow-prod.fluidtopics.net/~RcRS0fIXFTKT8Q8DZmQRw#PreferencesBothAPI "The Preferences API gets notification destinations for a user.") API. Before calling any methods in this class, you must call the Preferences.getDestinations() or
Preferences.getDestinationsByChannel() methods to instantiate a PreferenceDestination object.

This class uses the
`sn_notification`
namespace identifier.

## PreferenceDestination - getChannel() {#ariaid-title2}

Returns the channel that is used to send notifications to the destination.
{#PrefDest-getChannel__table_hhz_g4h_wnb__entry__3}

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

{#PrefDest-getChannel__table_hhz_g4h_wnb} {#PrefDest-getChannel__table_ihz_g4h_wnb__entry__2}

| Type | Description |
|-|-|
| GlideRecord | GlideRecord from the Notification Channel \[sys_notification_channel\] table for the channel that is used to send notifications to the destination. |
[Table 2. Returns]

{#PrefDest-getChannel__table_ihz_g4h_wnb}  
This example prints the channel that is used to send notifications for each of Abel Tuter's
destinations.

    var recipient = new GlideRecord('sys_user');
    recipient.get('last_name', 'Tuter');
    var prefs = new sn_notification.Preferences(recipient);
    var dests = prefs.getDestinations();
    for (var i=0; i<dests.length; i++) {
         gs.print('Channel for destination '+(i+1)+' is '+dests[i].getChannel().name); 
    }

Output:

    Channel for destination 1 is Workspace

## PreferenceDestination - getDeliverTo() {#ariaid-title3}

Returns the identifier for the destination.
{#PrefDest-getDeliverTo__table_uzj_k4h_wnb__entry__3}

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

{#PrefDest-getDeliverTo__table_uzj_k4h_wnb} {#PrefDest-getDeliverTo__table_vzj_k4h_wnb__entry__2}

| Type | Description |
|-|-|
| String | The identifier for the destination. For example, an email address, push application install token, or sys_id. |
[Table 4. Returns]

{#PrefDest-getDeliverTo__table_vzj_k4h_wnb}  
This example prints the identifier for each of Abel Tuter's destinations. The output shows
that the identifier for Abel's Workspace destination is the user sys_id.

    var recipient = new GlideRecord('sys_user');
    recipient.get('last_name', 'Tuter');
    var prefs = new sn_notification.Preferences(recipient);
    var dests = prefs.getDestinations();
    for (var i=0; i<dests.length; i++) {
         gs.print('The identifier for '+recipient.first_name+'\'s '+dests[i].getDestinationType().name+' destination is '+dests[i].getDeliverTo());
    }

Output:

    The identifier for Abel's Workspace destination is 62826bf03710200044e0bfc8bcbe5df1

## PreferenceDestination - getDestinationType() {#ariaid-title4}

Returns the type of destination, such as personal email or work email.
{#PrefDest-getDestinationType__table_fkz_34h_wnb__entry__3}

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

{#PrefDest-getDestinationType__table_fkz_34h_wnb} {#PrefDest-getDestinationType__table_gkz_34h_wnb__entry__2}

| Type | Description |
|-|-|
| GlideRecord | GlideRecord from the Notification Destination Type \[sys_notif_destination_type\] table for the destination type. |
[Table 6. Returns]

{#PrefDest-getDestinationType__table_gkz_34h_wnb}  
This example prints the identifier for each of Abel Tuter's destinations. The output shows
that the identifier for Abel's Workspace destination is the user sys_id.

    var recipient = new GlideRecord('sys_user');
    recipient.get('last_name', 'Tuter');
    var prefs = new sn_notification.Preferences(recipient);
    var dests = prefs.getDestinations();
    for (var i=0; i<dests.length; i++) {
         gs.print('The identifier for '+recipient.first_name+'\'s '+dests[i].getDestinationType().name+' destination is '+dests[i].getDeliverTo());
    }

Output:

    The identifier for Abel's Workspace destination is 62826bf03710200044e0bfc8bcbe5df1

## PreferenceDestination - isActive(GlideRecord notification) {#ariaid-title5}

Checks if the destination has permission to receive a notification.
{#PrefDest-isActive_O__table_j4d_bw3_wnb__entry__3}

| Name | Type | Description |
|-|-|-|
| notification | GlideRecord | Optional. Specify a notification to check if the destination has permission to receive that notification. An exception is thrown if the notification doesn't exist or if the notification isn't readable by the destination's user. If no notification is specified, this method checks if the destination has permission to receive any notifications. |
[Table 7. Parameters]

{#PrefDest-isActive_O__table_j4d_bw3_wnb} {#PrefDest-isActive_O__table_k4d_bw3_wnb__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the destination has permission to receive a notification. Valid values: * true: The destination has permission receive a notification. * false: The destination doesn't have permission to receive a notification. {#PrefDest-isActive_O__ul_jx4_bql_wnb} |
[Table 8. Returns]

{#PrefDest-isActive_O__table_k4d_bw3_wnb}  
This example checks if each of Abel Tuter's destinations has permission to receive the
Approval Request notification.

    var recipient = new GlideRecord('sys_user');
    recipient.get('last_name', 'Tuter');
    var prefs = new sn_notification.Preferences(recipient);
    var dests = prefs.getDestinations();
    var notif = new GlideRecord('sys_notification'); 
    notif.get('name', 'Approval Request'); 
    for (var i=0; i<dests.length; i++) {
       var active = dests[i].isActive(notif) ? 'active' : 'inactive'; 
       gs.print(dests[i].getDestinationType().name + ' ' + dests[i].getDeliverTo() + ' is ' + active + ' for this notification');
    }

Output:

    Workspace 62826bf03710200044e0bfc8bcbe5df1 is active for this notification

## PreferenceDestination - isOverriden(GlideRecord notification) {#ariaid-title6}

Checks if a notification overrides a user's preferences for the
destination.
{#PrefDest-isOverriden_O__table_s1c_5v3_wnb__entry__3}

| Name | Type | Description |
|-|-|-|
| notification | GlideRecord | Specify a notification to check if it overrides user preferences for the destination. The notification should be a GlideRecord from the Notification \[sys_notification\] table. |
[Table 9. Parameters]

{#PrefDest-isOverriden_O__table_s1c_5v3_wnb} {#PrefDest-isOverriden_O__table_t1c_5v3_wnb__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the notification overrides user preferences for the destination. Valid values: * true: User preferences for the destination are ignored for this notification. * false: The destination receives or doesn't receive the notification according to the user preference. {#PrefDest-isOverriden_O__ul_mcq_txl_wnb} |
[Table 10. Returns]

{#PrefDest-isOverriden_O__table_t1c_5v3_wnb}  
This example checks if the Approval Request notification overrides user preferences for one
of Abel Tuter's destinations. If the notification doesn't override user preferences, the
destination is given permission to receive the notification. Otherwise, no preference is set
because the notification overrides the preference.

    var recipient = new GlideRecord('sys_user');
    recipient.get('last_name', 'Tuter');
    var prefs = new sn_notification.Preferences(recipient);
    var dests = prefs.getDestinations();
    var notif = new GlideRecord('sys_notification'); 
    notif.get('name', 'Approval Request'); 
    var firstDest = dests[0]; 
    if (!firstDest.isOverridden(notif)) { 
         dests[0].setActive(notif, true); 
    } else { 
         gs.print('This notification overrides user preference, so don't bother to set a preference.'); 
    } 

## PreferenceDestination - setActive(GlideRecord notification, Boolean active) {#ariaid-title7}

Sets the user preference for a destination to receive or not receive
notifications.
The isOverriden() method can be called first to check if the user
preference will be ignored, but it is not required.
{#PrefDest-setActive_O_B__table_h3k_kw3_wnb__entry__3}

| Name | Type | Description |
|-|-|-|
| notification | GlideRecord | Optional. If a notification is specified, the user preference is set for the destination to receive or not receive that notification. The notification should be a GlideRecord from the Notification \[sys_notification\] table. If no notification is specified, the user preference is set for the destination to receive or not receive all notifications. |
| active | Boolean | Flag that indicates whether the destination has permission to receive a notification. Valid values: * true: The destination has permission receive a notification. * false: The destination doesn't have permission to receive a notification. {#PrefDest-setActive_O_B__ul_jx4_bql_wnb} |
[Table 11. Parameters]

{#PrefDest-setActive_O_B__table_h3k_kw3_wnb} {#PrefDest-setActive_O_B__table_i3k_kw3_wnb__entry__2}

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

{#PrefDest-setActive_O_B__table_i3k_kw3_wnb}  
This example checks if the Approval Request notification overrides user preferences for one
of Abel Tuter's destinations. If the notification doesn't override user preferences, the
destination is given permission to receive the notification. Otherwise, no preference is set
because the notification overrides the preference.

    var recipient = new GlideRecord('sys_user');
    recipient.get('last_name', 'Tuter');
    var prefs = new sn_notification.Preferences(recipient);
    var dests = prefs.getDestinations();
    var notif = new GlideRecord('sys_notification'); 
    notif.get('name', 'Approval Request'); 
    var firstDest = dests[0]; 
    if (!firstDest.isOverridden(notif)) { 
         dests[0].setActive(notif, true); 
    } else { 
         gs.print('This notification overrides user preference, so don't bother to set a preference.'); 
    } 


