I have a mapreduce script which loads a saved sear...
# suitescript
k
I have a mapreduce script which loads a saved search in the getinput stage. The search is then directly passed to reduce stage. In the reduce stage, after parsing the JSON context using following:
Copy code
var result = JSON.parse(context.values[0]);
log.debug('Result', result);
The logged result looks something like this:
Copy code
"recordType":"customrecord_vrt","id":"16","values":{"name":"ABC Report","created.file":"11/29/2022 4:07 pm","internalid.file":{"value":"12345","text":"12345"}}}
In the next step, I am trying to access
internalid.file
from the result. I have tried all methods that I know, but I am still not able to access it. Some of the steps I have taken to get
internalid.file
are:
Copy code
var fileId = result.getValue({ name: 'internalid', join: 'file' });

var fileId = result.values.internalid.file.value;
What am I missing here?
b
Copy code
result.values
has 3 keys
Copy code
name
created.file
internalid.file
Copy code
result.values.internalid
is an attempt to access the
Copy code
internalid
key, which does not exist and is undefined
use bracket_notation instead
k
Thank you! this worked:
Copy code
var fileId = result.values['internalid.file'].value;