When working with saved searches in Map/Reduce (M/R) scripts, developers often encounter a frustrating issue: multiple formulatext columns in the saved search result get collapsed into a single key in the mapContext.value object. This happens because NetSuite uses the column type (e.g., formulatext) as the key, and if multiple columns share the same type without unique identifiers, they overwrite each other.
The Problem
You’ve defined a saved search with several formulatext columns, each serving a different purpose. When you load this search in your M/R script and pass it from getInputData to map, the mapContext.value object ends up with only one formulatext key — the others are overwritten.
Why This Happens
NetSuite assigns keys in the result object based on the column type if no unique label is provided. So if you have:
formulatext(Customer Name)formulatext(Order Status)formulatext(Shipping Method)
They all get stored under the same key: formulatext.
Solution 1: Use Unique Labels in the Saved Search
The simplest and most effective solution is to assign unique labels to each formula column in your saved search. For example:
formulatext_customernameformulatext_orderstatusformulatext_shippingmethod
NetSuite will then use these labels as keys in the result object, preserving each value separately.
You can do this by:
- Editing the saved search.
- Clicking on the formula column.
- Setting a custom label in the “Custom Label” field.
This ensures that mapContext.value will contain:
{
formulatext_customername: “John Doe”,
formulatext_orderstatus: “Shipped”,
formulatext_shippingmethod: “FedEx”
}
Solution 2: Use SuiteQL Instead
If you need more control over the result structure, consider using SuiteQL instead of a saved search. SuiteQL returns results as an ordered array, which you can destructure easily in the map stage.
Example:
const results = query.runSuiteQL({ query: “SELECT … FROM …” }).asMappedResults();
This approach avoids the key collision issue entirely and gives you full control over column names and data types.
NetSuite’s official documentation also addresses this issue. You can find more details here:
🔗 SuiteAnswers Article #74736