{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":880,"path":"api-reference/server-api-reference/PreferencesBothAPI.md","title":"Preferences - Scoped, Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# Preferences - Scoped, Global\n\nThe Preferences API gets notification destinations for a user.\n\nA 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.\n\nUse this API with the [PreferenceDestination](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/PreferenceDestinationBothAPI.md) API to update user notification preferences.\n\nThis class uses the `sn_notification` namespace identifier.\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## Preferences - Preferences\\(GlideRecord recipient\\)\n\nInstantiates a Preferences object for a specified user.\n\n|Name|Type|Description|\n|----|----|-----------|\n|recipient|GlideRecord|GlideRecord from the User \\[sys\\_user\\] table for the user that you want to get notification destinations for.|\n\nThis example instantiates a Preferences object for the user Abel Tuter.\n\n```\nvar recipient = new GlideRecord('sys_user'); \nrecipient.get('last_name', 'Tuter'); \nvar prefs = new sn_notification.Preferences(recipient);\n```\n\n## Preferences - getDestinations\\(\\)\n\nReturns a user's notification destinations.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Array|Array of [PreferenceDestination](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/PreferenceDestinationBothAPI.md) objects. If the user doesn't have any destinations, the array is empty.|\n\nThis example gets all of Abel Tuter's notification destinations. The output shows that Abel has one destination.\n\n```\nvar recipient = new GlideRecord('sys_user'); \nrecipient.get('last_name', 'Tuter'); \nvar prefs = new sn_notification.Preferences(recipient);\nvar dests = prefs.getDestinations();\ngs.print(dests);\n```\n\nOutput:\n\n```\n[object PreferenceDestination]\n```\n\n## Preferences - getDestinationsByChannel\\(GlideRecord channel\\)\n\nReturns a user's notification destinations that use a specified channel.\n\n|Name|Type|Description|\n|----|----|-----------|\n|channel|GlideRecord|GlideRecord from the Notification Channel \\[sys\\_notification\\_channel\\] table for the channel you want to filter on.|\n\n|Type|Description|\n|----|-----------|\n|Array|Array of [PreferenceDestination](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/PreferenceDestinationBothAPI.md) 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.|\n\nThis 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.\n\n```\nvar recipient = new GlideRecord('sys_user'); \nrecipient.get('last_name', 'Tuter'); \nvar prefs = new sn_notification.Preferences(recipient);\nvar channel = new GlideRecord('sys_notification_channel');\nchannel.get('name', 'Workspace'); \nvar dests = prefs.getDestinationsByChannel(channel);\ngs.print(dests);\n```\n\nOutput:\n\n```\n[object PreferenceDestination]\n```\n\n"}}