Supista Documentation — Setup, Configuration & AI Workflow Guides
documentation
Supista ERP
Parameters
API Operations
CSV Upload

CSV Upload

CSV Upload in Supista ERP is a bulk data ingestion mechanism that allows users to upload tabular data (CSV/Excel) through the UI.

Supista does not pass raw CSV text to custom code.
Instead, the uploaded file is parsed into structured JSON and injected into the customization layer under a reserved key:

{
  "__d3__csvData": [ ... ]
}

How It Works

Each object inside __d3__csvData represents one row from the uploaded CSV file:

  • CSV headers → become object keys
  • CSV cell values → become object values
  • Empty cells → converted to null
  • Row order → preserved (important for error reporting)

Accessing CSV Data

Inside your customization function:

const csvData = userData?.__d3__csvData || [];

You can then transform these rows into a database-ready payload.


Example Implementation (Bulk Upsert)

async function customizeERP(userData, apiOperations) {
 
  const tableName = "employees";
  const { bulkCreateOp } = apiOperations;
 
  const csvData = userData?.__d3__csvData || [];
 
  // Map CSV rows directly to DB payload
  const bulkPayload = csvData.map(row => ({
    "Employees ID": row["Employees ID"],
    "Candidate_Name": row.Candidate_Name,
    "Email": row.Email,
    "Phone": row.Phone,
    "Date": row.Date
  }));
 
  // Perform Bulk UPSERT
  await bulkCreateOp(tableName, {
    __d3__bulkData: bulkPayload,
    __d3__updateOnDuplicate: true,
    __d3__conflictFields: ["Employees ID"]
  });
 
  return {
    result: {
      processed: bulkPayload.length
    },
    popupMsg: {
      type: "message",
      message: "CSV bulk upsert completed successfully."
    }
  };
}

Example Input

{
  "__d3__csvData": [
    {
      "Employees ID": 1,
      "Candidate_Name": "Mahender Singh",
      "Email": "wasamo3586@gavrom.com",
      "Phone": 7436452745
    }
  ]
}

Example Output (Error Format)

If validation or relational issues occur, structured row-level errors may be returned:

[
  {
    "Row Index": 223,
    "Error Type": "Upload Error",
    "Reason": "not_found",
    "Column Name": "3i736r6l16.Material Code",
    "Column Value": "RMBO174"
  }
]

Returning a Custom CSV File

In addition to importing CSV data, your customization can generate and return a custom CSV file. This is useful for scenarios such as:

  • Returning validation errors
  • Downloading rows that failed to import
  • Providing rejected records with error reasons
  • Exporting processed or transformed data
  • Any other custom reporting requirement

If your customization generates a CSV using generateCSV (or any other mechanism that returns CSV file IDs), return the response in the following format:

return {
  result: {
    fileIds: csvIds
  }
};

Where csvIds is an array of CSV file IDs returned by generateCSV.


Example

const csvResult = await generateCSV({
  title: "Upload Errors",
  rows: errorRows
});
 
return {
  result: {
    fileIds: csvResult.fileIds
  }
};

Note: When the customization returns CSV file IDs in the above format, Supista ERP automatically downloads the generated CSV file(s) after the customization finishes executing. This makes it easy to provide users with validation reports, rejected records, or any other custom CSV output without requiring any additional client-side implementation.

This structure helps identify exactly which row and column caused the issue during processing.

Transform Data into Decisions with Supista – Your Intelligent Data Partner
AI-Powered Operational Intelligence for Growing Businesses

Let AI run the operations. You drive the growth.

Book a free strategy session with our Automation Experts and discover how Supista’s AI-Composable ERP can transform your operations into a scalable and intelligent system.