Notification Operation – appNotification

The appNotification function is used to send real-time, in-app notifications to users within Supista ERP. These notifications help inform users of important actions, system events, workflow updates, or custom triggers (like approvals or reminders).

Notifications appear in the UI and can optionally link to a specific page or record, making them actionable and context-aware.

const notification = await appNotification(tableName, data);

Parameters

ParameterTypeDescription
tableNamestringThe name of the main table associated with the context of the notification.
dataobjectThe configuration object that defines the message content, recipient logic, and URL.

data (object, required)

Contains all the necessary information to construct and deliver the notification.

data.message (object, required)

Defines the message content.

  • data.message.title (string, required) Title shown in the notification popup.

  • data.message.body (string, required) Body text shown beneath the title.

data.to (object, required)

Defines the recipients of the notification.

  • data.to.teams (array, optional) Array of team IDs to notify.

  • data.to.users (array, optional) Array of user IDs to notify.

You can send to one or both: teams and/or users.

data.rowData (object, required)

The actual row of data relevant to the notification. Used to inject dynamic values into the message via templating.

data.url (string, required)

The URL to which the user will be redirected when clicking the notification.


Return Value

Returns a Promise that resolves with the result of the notification request.


Example Code

async function customizeERP(userData, apiOperations) {
  const tableName = "table_name";
  return new Promise(async (resolve, reject) => {
    try {
      if (!userData || userData.length === 0) {
        resolve({
          result: {},
          popupMsg: {
            type: 'error',
            message: "Invalid user data provided."
          }
        });
      }
 
      const row = userData[0];
      const recipientUserId = row?.user;
 
      if (!recipientUserId) {
        resolve({
          result: {},
          popupMsg: {
            type: 'error',
            message: "Missing 'user' field in the data."
          }
        });
      }
 
      const notificationPayload = {
        message: {
          title: "Notification",
          body: "this is a notification ignore it please"
        },
        to: {
          teams: ["82148650-38b3-11f0-a6f9-e13b163c86a7"], // Replace with your team ID
          users: [recipientUserId]
        },
        rowData: row,
        url: "https://link_to_redirect/" // Replace with your redirect link
      };
 
      const notificationResult = await appNotification(tableName, notificationPayload);
      resolve({
        result: { notificationResult },
        popupMsg: {
          type: "message",
          message: "Notification sent successfully."
        }
      });
    } catch (error) {
      resolve({
        result: {},
        popupMsg: {
          type: "message",
          message: `Notification failed: ${error.message}`
        }
      });
    }
  });
}

Example Input

[
  {
    "id": 1,
    "name": "sample",
    "bio": "this is a notification input example",
    "User": 121,
    "__d3__createdBy": 212,
    "__d3__lastUpdatedBy": 212,
    "__d3__createdAt": "2025-05-20T10:46:30.945Z",
    "__d3__updatedAt": "2025-06-13T07:44:52.581Z",
    "__d3__deletedAt": null
  }
]
Last updated on
Transform Data into Decisions with Supista – Your Intelligent Data Partner
This website uses cookies to improve user experience. By using our website you consent to all cookies in accordance with our Cookie Policy. Learn More.