The steps to be followed are as follows:
- Get the sublist ID
- Get the number of lines present (LineCount)
- Use the FOR LOOP to iterate within those lines, and make changes accordingly.
- After making the changes, commit the line
- Finally, save the record
//Loading the record - Invoice
var recordInvoice = record.load({
type: record.Type.INVOICE,
id: 276
});
So firstly, you will require to fetch the ID of that sublist containing the 'description' field. (In most of the cases its item
, I'll go with it).
Next, get the number of lines.
var numLines = record.getLineCount({
sublistId: 'item'
});
Using FOR Loop, iterate through the lines. Make sure you select the line and use correct syntax
for(var j=0; j<numLines; j++) {
record.selectLine({
sublistId: 'item',
line: j
)};
var descriptionValue = record.getCurrentSublistValue({
sublistId: 'item',
fieldId: 'description' //Try finding this value using &xml=t
});
if(descriptionValue) {
record.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'yourfield',
value: 'your value'
});
}
record.commitLine({
sublistId: 'item'
});
}
record.save();
Try this out, let me know if you face any issues in the comments.