變更記錄的通知條件的設置

information

本頁面使用機器翻譯而成。
機器翻譯免責聲明 (External link)

目錄

變更記錄的通知條件的設置

變更記錄的通知條件的設置。

此 API 可變更測試環境中的應用。
如果要將變更套用到正式環境,請在執行該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」中指定了選擇組織欄位時才有效。
如果省略,則設置「false」。
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.api()請求使用

有關詳細的kintone.api(),請參閱以下頁面。
發送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
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);