AppActivity Operation
For best practices on optimizing execution, scalability, and performance, see:
Performance and Efficiency Guidelines
Function Name
const activityPrompt = await appActivity(activityPayload)Purpose
The function accepts a structured object payload and processes it to create a system activity record.
Parameters (GPT Reference)
data
- Type: object
- Required: ✅
- Description: Object containing required information for sending/logging the activity
data.schema
- Type: object
- Required: ✅
- Description: Schema of the activity body
data.schema.body
- Type: string
- Required: ✅
- Description: The main message text for the activity
data.schema.systemActivity
- Type: boolean
- Required: ✅
- Description: Indicates if activity is generated by system instead of user
data.rowData
- Type: object
- Required: ✅
- Description: Row level data to populate dynamic fields
data.rowData.id
- Type: number
- Required: ✅
- Description: Unique identifier to associate activity with a record
rowData Section
This section contains the complete row object context.
The fields from rowData are used to populate the body template dynamically.
Example Usage
The input data object must follow a strict structure. It contains two main sections:
{
"schema": {
"body": "string (Required)",
"systemActivity": "boolean (Required)"
},
"rowData": {
"id": "number (Required)",
"...other fields": "dynamic fields from the row"
}
}Example Code
async function customizeERP(userData, apiOperations) {
const tableName = "tableName";
let isError = false;
let errorMsg = "";
if (userData && userData.length > 0) {
const returnData = await Promise.all(
userData.map(async (row) => {
let activityPayload = {
schema: {
body: `Quotation price for <strong>{{itemName}}</strong> in organisation {{organisation}} has increased from {{lastPurchasePrice}} to {{newQuotedPrice}}`,
systemActivity: true
},
rowData: {
...row
}
}
const activityPrompt = await appActivity(activityPayload)
return activityPrompt
})
);
if (isError) {
return ({
result: returnData,
popupMsg: {
type: "error",
message: errorMsg
}
});
}
else {
return ({
result: returnData
});
}
}
}Example Input
[
{
"organisation": "Acme Robotics Ltd",
"itemName": "Industrial Servo Motor",
"lastPurchasePrice": 1200,
"newQuotedPrice": 1275,
"id": 45
}
]
---