The csv file should like shown as below.
The following code is given in getInputData().
The internal id of the csv file is given as id in file.load.
let file1 = file.load({id: 1116983});
let fileContents = file1.getContents();
log.debug(“contents”,fileContents)
let valFile=papa.parse(fileContents,{
header:true,
skipEmptyLines:true
}).data;
log.debug(“val”,valFile)
return valFile;
Then following code is used in reduce stage
let jsonObject=JSON.parse(reduceContext.values);
// Fetch individual values
let internalId = jsonObject[‘Internal ID’];
let documentNumber = jsonObject[‘Document Number’];
let costAllocationMethod = jsonObject[‘Cost Allocation Method’];
let freight = jsonObject[‘Freight’];
let customs = jsonObject[‘Customs’];
let others = jsonObject[‘Others’];
//log.debug(“intid”,internalId);
record.submitFields({
type: record.Type.ITEM_RECEIPT,
id: internalId,
values: {
landedcostmethod:costAllocationMethod,
landedcostamount1: freight,
landedcostamount2: customs,
landedcostamount3: others
}
});