Skip to content

informat.notification system notification

Overview

Use informat.notification to perform operations on system notifications.

queryNotificationListCount

Query the total count of system notifications that match the filter condition.

javascript
informat.notification.queryNotificationListCount(filter);
ParameterTypeDescription
filterFilterFilter condition

Fields available for filtering

FieldTypeDescription
idStringSystem notification ID
accountIdStringAccount ID
nameStringName
typeStringType
contentStringContent
isReadBooleanWhether it has been read
isWebSendStringWhether sent via web
isDingTalkSendStringWhether sent via DingTalk
isFeishuSendStringWhether sent via Feishu
createTimeStringCreation time

Return value

Type: Integer Returns the total count of system notifications that match the filter condition.

Example

javascript
const count = informat.notification.queryNotificationListCount({
  conditionList: [
    {
      fieldId: "accountId",
      opt: "eq",
      value: "x38s0fa436v69",
    },
  ],
});
// Get the matched list
console.log("count:", count);

queryNotificationList

Query the system notification list that matches the query condition.

javascript
informat.notification.queryNotificationList(query);
ParameterTypeDescription
queryQueryQuery condition

Fields available for filtering

FieldTypeDescription
idStringSystem notification ID
accountIdStringAccount ID
nameStringName
typeStringType
contentStringContent
isReadBooleanWhether it has been read
isWebSendStringWhether sent via web
isDingTalkSendStringWhether sent via DingTalk
isFeishuSendStringWhether sent via Feishu
createTimeStringCreation time

Return value

Type: Array<Notification> Returns the system notification list that matches the query condition.

Example

javascript
const notificationList = informat.notification.queryNotificationList({
  pageIndex: 1,
  pageSize: 20,
  filter: {
    conditionList: [
      {
        fieldId: "accountId",
        opt: "eq",
        value: "x38s0fa436v69",
      },
    ],
  },
});
// Get the system notification list
console.log("notificationList:", notificationList);

updateNotification

Update the system notification.

javascript
informat.notification.updateNotification(notification);
ParameterTypeDescription
notificationNotificationSystem notification

Fields available for updating

FieldTypeDescription
isWebSendBooleanWhether sent via websocket
isWeworkSendBooleanWhether sent via enterprise Wechat
isDingTalkSendBooleanWhether sent via DingTalk
isFeishuSendBooleanWhether sent via Feishu
isCustomSendBooleanWhether sent via custom notification

Return value

Type: Integer Returns the number of records updated.

Example

javascript
informat.notification.updateNotification({
  id: "e15ab1jmdjyl8",
  isWebSend: true,
  isWeworkSend: true,
  isDingTalkSend: true,
  isFeishuSend: true,
  isCustomSend: true,
});

deleteNotification

Delete the system notification.

javascript
informat.notification.deleteNotification(id);
ParameterTypeDescription
idStringSystem notification ID

Return value

Type: Integer Returns the number of records deleted.

Example

javascript
informat.notification.deleteNotification("b8ynqdu6z31ry");

queryCustomNotificationListCount

Query the total count of system notifications that match the filter condition and have not been sent via custom notification.

javascript
informat.notification.queryCustomNotificationListCount(filter);
ParameterTypeDescription
filterFilterFilter condition

Fields available for filtering

FieldTypeDescription
idStringSystem notification ID
accountIdStringAccount ID
nameStringName
typeStringType
contentStringContent
isWebSendStringWhether sent via websocket
isDingTalkSendStringWhether sent via DingTalk
isFeishuSendStringWhether sent via Feishu
createTimeStringCreation time

Return value

Type: Integer Returns the total count of system notifications that match the filter condition.

Example

javascript
const count = informat.notification.queryCustomNotificationListCount({
  conditionList: [
    {
      fieldId: "accountId",
      opt: "eq",
      value: "x38s0fa436v69",
    },
  ],
});
// Get the matched list
console.log("count:", count);

queryCustomNotificationList

Query the system notification list that match the filter condition and have not been sent via custom notification.

javascript
informat.notification.queryCustomNotificationList(query);
ParameterTypeDescription
queryQueryQuery condition

Fields available for filtering

FieldTypeDescription
idStringSystem notification ID
accountIdStringAccount ID
nameStringName
typeStringType
contentStringContent
isWebSendStringWhether sent via websocket
isDingTalkSendStringWhether sent via DingTalk
isFeishuSendStringWhether sent via Feishu
createTimeStringCreation time

Return value

Type: Array<Notification> Returns the system notification list that match the filter condition.

Example

javascript
const notificationList = informat.notification.queryCustomNotificationList({
  pageIndex: 1,
  pageSize: 20,
  filter: {
    conditionList: [
      {
        fieldId: "accountId",
        opt: "eq",
        value: "x38s0fa436v69",
      },
    ],
  },
});
// Get the matched list
console.log("notificationList:", notificationList);

sendNotification

Send the system notification.

javascript
informat.notification.sendNotification(notification);
ParameterTypeDescription
notificationNotificationFormSystem notification form

Return value

Type: String Returns the system notification ID.

Example

javascript
const notificationId = informat.notification.sendNotification({
  title: "Notification title",
  content: "Notification content",
  accountId: informat.app.userId(),
  type: "openurl", // openurl||openrecord|openbpmntask
  urlSetting: {
    url: "https://next.informat.cn/",
    isAppURL: false,
  },
  recordSetting: {
    recordId: null,
    moduleId: null,
  },
  bpmnTaskSetting: {
    taskId: null,
    moduleId: null,
  },
});
// Get the notification ID
console.log("notificationId:", notificationId);

setCustomNotificationSent

Set the custom notification as sent.

TIP

Setting the notification as sent will update the notificationSent.isCustomSend field to true (sent).

javascript
informat.notification.setCustomNotificationSent(notificationId);
ParameterTypeDescription
notificationIdStringSystem notification ID

Example

javascript
const notificationList = informat.notification.queryCustomNotificationList({
  pageIndex: 1,
  pageSize: 20,
  filter: {
    conditionList: [
      {
        fieldId: "accountId",
        opt: "eq",
        value: "x38s0fa436v69",
      },
    ],
  },
});
notificationList.forEach((notification) => {
  console.log("notification:", notification);
  // do smth
  informat.notification.setCustomNotificationSent(notification.id);
});

setThreadLocalEnableNotify

Setting the thread-local variable to enable/disable notifications for the current application.

javascript
informat.notification.setThreadLocalEnableNotify(enable);
ParameterTypeDescription
enableBooleanWhether to enable notifications

Example

javascript
informat.notification.setThreadLocalEnableNotify(true);

isThreadLocalEnableNotify

Get the thread-local variable that indicates whether notifications are enabled for the current app.

javascript
informat.notification.isThreadLocalEnableNotify();

Return value

Type: Boolean Returns whether notifications are enabled.

Example

javascript
informat.notification.isThreadLocalEnableNotify();