My mapreduce script code file starts (after the ne...
# suiteanalytics
a
My mapreduce script code file starts (after the necessary NApiVersion and NScriptType tags) with:
Copy code
define(["N/runtime", "N/search", "N/dataset", "N/record"], function(runtime, search, dataset, record){
When executing the line
Copy code
const datasetObj = dataset.loadDataset({id: datasetId});
I get this error:
Copy code
TypeError: dataset.loadDataset is not a function
But the NetSuite Help documentation shows this: dataset.loadDataset(options) Method Description Loads an existing dataset. Returns dataset.Dataset Supported Script Types Server scripts For more information, see SuiteScript 2.x Script Types. Governance 10 units Module N/dataset Module Sibling Module Members N/dataset Module Members Since 2020.2 Parameters Note The
options
parameter is a JavaScript object. Parameter Type Required / Optional Description
options.id
string required The ID of the dataset to load. So why is a function the docs say is there, not there? I'm going to use query.load() instead. That doesn't throw errors and seems to return all the dataset results into the map function
1
a
I would guess you're overwriting the dataset module with a variable assignment
but without seeing the rest of the code I'm just guessing
a
no, I checked, the "dataset" keyword is not being assigned to anything, only dereferenced. Good idea, though.
a
its apparently mis-named in the docs it appears to be just "load"
netsuite 1
k
try this const datasetObj = dataset.load({ id: datasetId });
a
Thank you everyone. I'll keep that in mind for next time. I wondered if that was the case (misnamed in the documentation), but I ended up going with query.load() and it worked just right.