Action Buttons
Action buttons enable custom workflows directly from the UI. These buttons are tied to specific logic and may operate on one or more selected rows.
Action buttons are used to trigger specific actions when clicked by the user. These actions can include:
- Sending data or PDF files as emails or messages.
- Downloading a PDF file.
- Making updates or changes in the database.
Action buttons provide a way to implement custom workflows and automate processes directly from the user interface.
Role-Based Visibility
Users can define trigger conditions to control:
-
When the button will be visible:
Based on specific cases, such as data attributes, form states, or user interactions. -
Who can see the button:
Visibility can be restricted to certain user roles, enabling role-based actions for enhanced security and usability.
For example, an action button to "Approve Requests" can be visible only to users with an Admin or Manager role.
Sample Implementation
Below is a sample implementation of an Action Button in Supista ERP:
async function customizeERP(userData, apiOperations) {
const tableName = "table_name";
if (userData && userData.length > 0) {
const returnData = await Promise.all(userData.map(async (row) => {
// Your Code Starts Here
}));
return returnData;
}
}
Output Structure
{
"result": {
"affectedCount": [1],
"pdfIDs": []
}
}
Example Code
async function customizeERP(userData, apiOperations) {
const tableName = "table_name";
if (userData && userData.length > 0) {
return await Promise.all(userData.map(async (row) => {
return new Promise(async (resolve, reject) => {
const payload = {
__d3__id: row?.id,
__d3__newData: {
status: "approved"
}
};
const updatedData = await updateOp(tableName, payload);
if (updatedData?.affectedCount?.[0]) {
resolve({ result: updatedData });
} else {
resolve({
result: {},
popupMsg: {
type: "error",
message: "Could Not update data! Please try again later"
}
});
}
});
}));
} else {
resolve({
result: {},
popupMsg: {
type: "error",
message: "No rows selected for the action."
}
});
}
}
Example Input
[
{
"id": 1,
"status": "dismissed",
"__d3__createdBy": 575,
"__d3__lastUpdatedBy": 575,
"__d3__createdAt": "2025-05-20T10:47:00.976Z",
"__d3__updatedAt": "2025-06-11T13:16:29.818Z",
"__d3__deletedAt": null
}
]
Example Output
{
"response": {
"__d3__result": [
{
"result": {
"affectedCount": [
1
]
}
}
],
"__d3__error": false,
"printConsole": []
}
}