//Info: JOIN-205
var test = dataObj.values.custbody_celigo_etail_order_id
log.debug("etailId",test)
var mainRecord = dataObj.values.internalid[0].value
log.debug("recordInternalid",mainRecord)
//search for invoice order id
var invoiceSearchObj = search.create({
type: "invoice",
filters:
[
["type","anyof","CustInvc"],
"AND",
["custbody_celigo_etail_order_id","is",test],
"AND",
["mainline","is","T"]
],
columns:
[
search.createColumn({name: "internalid", label: "Internal ID"})
]
});
var searchResult = invoiceSearchObj.run().getRange({
start: 0,
end: 1
});
var internal_id = searchResult[0].getValue({name: "internalid", label: "Internal Id"})
log.debug('internalId Invoice',internal_id)
//load invoice order
var invoice_rec = record.load({
type: record.Type.INVOICE,
id: internal_id,
isDynamic: true,
})
var class_id;
for(i=0;i<1;i++)
{
invoice_rec.selectLine({
sublistId: 'item',
line: i
});
class_id = invoice_rec.getCurrentSublistValue({
sublistId: 'item',
fieldId: 'class',
});
log.debug("classId",class_id)
}
var recType= dataObj.recordType
log.debug("recordType",recType)
var custRec = record.load({
type: recType.toString(),
id: mainRecord,
isDynamic: true
})
log.debug("record",custRec)
var mainClass = custRec.getValue({
fieldId: 'class'
})
log.debug("mainClass_id",mainClass)
if (mainClass !== class_id)
{
log.debug("final")
custRec.setValue({
fieldId: 'class',
value: class_id
})
custRec.save()
}
Note:
This part is added under Reduce context stage in MapReduce script.
‘dataObj’ , which is mentioned initially holds the value of records that the user chooses. This can be done in getInputData stage.