Preferences - Scoped, Global

  • Release version: Zurich
  • Updated July 31, 2025
  • 1 minute to read
  • The Preferences API gets notification destinations for a user.

    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.

    Use this API with the PreferenceDestination API to update user notification preferences.

    This class uses the sn_notification namespace identifier.

    Preferences - Preferences(GlideRecord recipient)

    Instantiates a Preferences object for a specified user.

    Table 1. Parameters
    Name Type Description
    recipient GlideRecord GlideRecord from the User [sys_user] table for the user that you want to get notification destinations for.

    This example instantiates a Preferences object for the user Abel Tuter.

    var recipient = new GlideRecord('sys_user'); 
    recipient.get('last_name', 'Tuter'); 
    var prefs = new sn_notification.Preferences(recipient);

    Preferences - getDestinations()

    Returns a user's notification destinations.

    Table 2. Parameters
    Name Type Description
    None
    Table 3. Returns
    Type Description
    Array Array of PreferenceDestination objects. If the user doesn't have any destinations, the array is empty.

    This example gets all of Abel Tuter's notification destinations. The output shows that Abel has one destination.

    var recipient = new GlideRecord('sys_user'); 
    recipient.get('last_name', 'Tuter'); 
    var prefs = new sn_notification.Preferences(recipient);
    var dests = prefs.getDestinations();
    gs.print(dests);

    Output:

    [object PreferenceDestination]

    Preferences - getDestinationsByChannel(GlideRecord channel)

    Returns a user's notification destinations that use a specified channel.

    Table 4. Parameters
    Name Type Description
    channel GlideRecord GlideRecord from the Notification Channel [sys_notification_channel] table for the channel you want to filter on.
    Table 5. Returns
    Type Description
    Array Array of PreferenceDestination objects. If the user doesn't have any notification destinations that use the channel or if the channel doesn't exist, the array is empty.

    This example gets all of Abel Tuter's destinations that use the Workspace channel. The output shows that Abel has one destination that uses the Workspace channel.

    var recipient = new GlideRecord('sys_user'); 
    recipient.get('last_name', 'Tuter'); 
    var prefs = new sn_notification.Preferences(recipient);
    var channel = new GlideRecord('sys_notification_channel');
    channel.get('name', 'Workspace'); 
    var dests = prefs.getDestinationsByChannel(channel);
    gs.print(dests);

    Output:

    [object PreferenceDestination]