Maira S
Maira S

Reputation: 47

How to email dataset results in a CSV format using scheduled script?

I am using a NetSuite dataset (N/dataset API in SuiteScript 2.1) to retrieve existing dataset results. The dataset returns results in JSON format, including columns like PO Status, Billing Status, Sub Product, and Subsidiary.

However, instead of meaningful text values, some fields return unexpected codes:

PO Status: "F" or "D" instead of Partially Received.

Billing Status: "A" instead of Open.

Sub Product: 20 instead of a sub product name.

Subsidiary: 2/7, which seems internal ids

I cannot map these values statically because more values may be added in the future.

What I Tried

Used row.values[index] to extract values.

Looked for a .getText() method, but it doesn't work with datasets.

Checked if join in the dataset query was affecting the values.

Expected vs. Actual Results

Expected: "Purchase Order: Parially received", "Bill:Open", "Product Name", "Subsidiary Name" Actual: "D", "A", "20", "2"

Question

  1. Why does the dataset return codes (F/D, A, 2/7) instead of readable text?

  2. How can I dynamically convert these internal values into their corresponding text labels?

function execute(context) {

            // Load dataset
            let myDataset = dataset.load({ id: 'custdataset70' });
 
            // Run dataset and get results
             let results = myDataset.run();
  }

Upvotes: 0

Views: 45

Answers (1)

cesar parra
cesar parra

Reputation: 31

You should create a formula column for each column where you want to display the value instead of the id, and use #display to pull the display value. For instance {status#display}

Upvotes: 0

Related Questions