レコードの条件通知の設定を変更する

目次

レコードの条件通知の設定を変更する

レコードの条件通知の設定を変更します。

この API は、動作テスト環境のアプリを変更します。
本番環境に変更を反映する場合、この API を実行した後に アプリ設定を運用環境へ反映する API を実行してください。

URL

通常のアプリ
https://sample.cybozu.com/k/v1/preview/app/notifications/perRecord.json
ゲストスペースのアプリ
https://sample.cybozu.com/k/guest/GUEST_SPACE_ID/v1/preview/app/notifications/perRecord.json

HTTPメソッド

PUT

必要なアクセス権

  • アプリ管理権限

リクエスト

パラメーター
パラメーター名 必須 説明
app 数値または文字列 必須 アプリ ID
notifications 配列 省略可 レコードの条件通知の設定の一覧
通知設定を追加、更新するときは、既存の通知設定を notifications[].entity に指定してください。指定しない通知設定は削除されます。
通知設定をすべて削除する場合は、空配列を指定します。
notifications を省略した場合は変更されません。
notifications[].filterCond 文字列 条件必須 レコードの条件
クエリ形式で指定します。クエリ形式は、 クエリの書き方 を参照してください。
notifications を指定する場合は必須です。省略するとすべてのレコードが対象になります。
notifications[].title 文字列 省略可 通知内容
省略すると空文字が設定されます。
notifications[].targets 配列 条件必須 通知先の対象
notifications を指定する場合は必須です。
空配列を指定すると、既存の通知先をすべて削除します。
notifications[].targets[].entity オブジェクト 条件必須 通知先の対象
targets を指定する場合は必須です。
notifications[].targets[].entity.type 文字列 条件必須 通知先の対象の種類
  • USER:ユーザー
  • GROUP:グループ
  • ORGANIZATION:組織
  • FIELD_ENTITY:「フォームのフィールドを追加」として指定するフィールド
entity を指定する場合は必須です。
notifications[].targets[].entity.code 文字列 条件必須 通知先の対象のコード
entity.type の値によって異なります。
  • 「USER」の場合:ユーザーのログイン名
  • 「GROUP」の場合:グループコード
  • 「ORGANIZATION」の場合:組織コード
  • 「FIELD_ENTITY」の場合:次のフィールドのフィールドコードを指定します。
    • 作成者
    • 更新者
    • ユーザー選択
    • 組織選択
    • グループ選択
ゲストユーザーの場合、ログイン名の前に「guest/」が付きます。
notifications[].targets[].includeSubs 真偽値または文字列 省略可 設定を下位組織に継承するかどうか
  • true:継承する
  • false:継承しない
省略すると「false」が設定されます。
entity.type が「ORGANIZATION」か、「FIELD_ENTITY」で組織選択フィールドが指定されている場合のみ有効です。
revision 数値または文字列 省略可 期待しているリビジョン番号
実際のリビジョン番号と一致しない場合はエラーとなり、設定は変更されません。
値に「-1」を指定する、または指定しなかった場合はリビジョン番号は検証されません。
リクエストの例
ヘッダー
1
2
3
4
{
  "X-Cybozu-API-Token": "API_TOKEN",
  "Content-Type": "application/json"
}

リクエストヘッダーの詳細は kintone REST API の共通仕様 を参照してください。

ボディ
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{
  "app": "1",
  "notifications": [
    {
      "filterCond": "ユーザー選択フィールド in (\"user1\")",
      "title": "user1が選択されました",
      "targets": [
        {
          "entity": {
            "type": "USER",
            "code": "user1"
          }
        }
      ]
    },
    {
      "filterCond": "グループ選択フィールド in (\"org1\")",
      "title": "org1が選択されました",
      "targets": [
        {
          "entity": {
            "type": "ORGANIZATION",
            "code": "org1"
          },
          "includeSubs": "true"
        }
      ]
    }
  ],
  "revision": "2"
}

レスポンス

プロパティ
プロパティ名 値の種類 説明
revision 文字列 アプリの設定を変更したあとのリビジョン番号
レスポンスの例
1
2
3
{
  "revision": "2"
}

サンプルコード

curlを使ったリクエスト
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
curl -X PUT 'https://sample.cybozu.com/k/v1/preview/app/notifications/perRecord.json' \
  -H 'X-Cybozu-API-Token: API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "app": "1",
    "notifications": [
      {
        "filterCond": "ユーザー選択フィールド in (\"user1\")",
        "title": "user1が選択されました",
        "targets": [
          {
            "entity": {
              "type": "USER",
              "code": "user1"
            }
          }
        ]
      },
      {
        "filterCond": "グループ選択フィールド in (\"org1\")",
        "title": "org1が選択されました",
        "targets": [
          {
            "entity": {
              "type": "ORGANIZATION",
              "code": "org1"
            },
            "includeSubs": "true"
          }
        ]
      }
    ],
    "revision": "2"
  }'
kintone REST API リクエストを送信する API を使ったリクエスト
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const body = {
  app: '1',
  notifications: [
    {
      filterCond: 'ユーザー選択フィールド in ("user1")',
      title: 'user1が選択されました',
      targets: [
        {
          entity: {
            type: 'USER',
            code: 'user1'
          }
        }
      ]
    },
    {
      filterCond: 'グループ選択フィールド in ("org1")',
      title: 'org1が選択されました',
      targets: [
        {
          entity: {
            type: 'ORGANIZATION',
            code: 'org1'
          },
          includeSubs: 'true'
        }
      ]
    }
  ],
  revision: '2'
};

await kintone.api(kintone.api.url('/k/v1/preview/app/notifications/perRecord.json', true), 'PUT', body);