let poRecord = record.load({
type: record.Type.PURCHASE_ORDER,
id: '<purchaseorderinternalid>',
isDynamic: true,
});
let relatedRecords = {
'irArray': [],
'billArray': []
};
let numLinesIR = poRecord.getLineCount({
sublistId: 'links'
});
for (let i = 0; i < numLinesIR; i++) {
let type = poRecord.getSublistValue({
fieldId: 'type',
sublistId: 'links',
line: i
});
if (type === 'Item Receipt') {
let receiptId = poRecord.getSublistValue({
fieldId: 'id',
sublistId: 'links',
line: i
});
relatedRecords.irArray.push(receiptId);
} else if (type === 'Bill') {
let billId = poRecord.getSublistValue({
fieldId: 'id',
sublistId: 'links',
line: i
});
relatedRecords.billArray.push(billId);
}
}