---
sourceDocument: Xanadu API リファレンス
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - ja-JP

ft:publication_title :

    - Xanadu API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Preferences - スコープ指定、グローバル

# Preferences - スコープ指定、グローバル {#ariaid-title1}

* リリースバージョン: Xanadu
* 
* 更新日 2024年08月01日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：3分

Preferences API は、ユーザーの通知宛先を取得します。

通知の宛先は、特定のメールアドレスや電話番号など、通知を配信できる場所です。この API は、通知 \[sys_notification\] テーブルからの通知に基づいています。通知は、メールや ワークスペース などのチャネルを介して送信されます。チャネルを使用して、複数のタイプの宛先に通知を送信できます。たとえば、メールチャネルは、個人用メールと仕事用メールの両方の宛先に通知を送信できます。宛先タイプは、通知宛先タイプ \[sys_notif_destination_type\] テーブルにリストされています。

この API を [PreferenceDestination](https://servicenow-prod.fluidtopics.net/seoeCzD_ss82pufct5Li~A#PreferenceDestinationBothAPI "PreferenceDestination API は、ユーザーの通知設定を更新します。") API とともに使用して、ユーザー通知設定を更新します。

このクラスは、 `sn_notification` 名前空間識別子を使用します。

## Preferences - Preferences(GlideRecord recipient) {#ariaid-title2}

指定されたユーザーの初期設定オブジェクトをインスタンス化します。
{#Preferences-Preferences_O__table_bkn_fx3_wnb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| recipient | GlideRecord | 通知宛先を取得するユーザーに対するユーザー sys_user テーブルの GlideRecord。 |
[表 : 1. パラメーター]

{#Preferences-Preferences_O__table_bkn_fx3_wnb}  
この例では、ユーザーである Abel Tuter さんの初期設定オブジェクトをインスタンス化します。

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

## Preferences - getDestinations() {#ariaid-title3}

ユーザーの通知宛先を返します。
{#Preferences-getDestinations__table_ept_hx3_wnb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 2. パラメーター]

{#Preferences-getDestinations__table_ept_hx3_wnb} {#Preferences-getDestinations__table_fpt_hx3_wnb__entry__2}

| タイプ | 説明 |
|-|-|
| アレイ | [PreferenceDestination](https://servicenow-prod.fluidtopics.net/seoeCzD_ss82pufct5Li~A#PreferenceDestinationBothAPI "PreferenceDestination API は、ユーザーの通知設定を更新します。") オブジェクトのアレイ。ユーザーに宛先がない場合、アレイは空です。 |
[表 : 3. 返される内容]

{#Preferences-getDestinations__table_fpt_hx3_wnb}  
この例では、Abel Tuter さんのすべての通知宛先を取得します。出力は、Abel さんの宛先が 1 つであることを示しています。

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

出力：

    [object PreferenceDestination]

## Preferences - getDestinationsByChannel(GlideRecord チャネル) {#ariaid-title4}

指定したチャネルを使用するユーザーの通知宛先を返します。
{#Preferences-getDestinationsByChannel_O__table_x4m_lx3_wnb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| channel | GlideRecord | フィルタリングを行うチャネルに対する通知チャネル \[sys_notification_channel\] テーブルからの GlideRecord。 |
[表 : 4. パラメーター]

{#Preferences-getDestinationsByChannel_O__table_x4m_lx3_wnb} {#Preferences-getDestinationsByChannel_O__table_y4m_lx3_wnb__entry__2}

| タイプ | 説明 |
|-|-|
| アレイ | [PreferenceDestination](https://servicenow-prod.fluidtopics.net/seoeCzD_ss82pufct5Li~A#PreferenceDestinationBothAPI "PreferenceDestination API は、ユーザーの通知設定を更新します。") オブジェクトのアレイ。ユーザーがチャネルを使用する通知宛先を持っていない場合、またはチャネルが存在しない場合、アレイは空です。 |
[表 : 5. 返される内容]

{#Preferences-getDestinationsByChannel_O__table_y4m_lx3_wnb}  
この例では、ワークスペースチャネルを使用する Abel Tuter さんのすべての宛先を取得します。出力は、ワークスペースチャネルを使用する Abel さんの宛先が 1 つであることを示しています。

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

出力：

    [object PreferenceDestination]


