Can we use a record.getSublistValue during the vie...
# suitescript
t
Can we use a record.getSublistValue during the view mode?
m
no. you can load the record and then set the sublist value and then save the record and reload the page
t
so let say I wanted to get the value of the a column, I should do this once the record load and store it somewhere if I want to access it
How about if I use the CurrentRecord.getSublistValue?
m
it should look similar to to get a value of a specific line.
Copy code
var objRecord = record.load({
    type: record.Type.SALES_ORDER,
    id: 157,
    isDynamic: true,
});

var lineNum = objRecord.selectLine({
    sublistId: 'item',
    line: 3
});

var sublistValue = objRecord.getCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'item'
});
You can also loop through the lines and get the line count with
Copy code
var objRecord = record.load({
    type: record.Type.SALES_ORDER,
    id: 157,
    isDynamic: true,
});

var numLines = objRecord.getLineCount({
    sublistId: 'item'
});

for(let i = 0; i < numLines; i++ ) {
var lineNum = objRecord.selectLine({
    sublistId: 'item',
    line: i
});

var sublistValue = objRecord.getCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'item'
});
}
t
thanks @Matt Bernstein
I'll check this out 🙂
m
and then if you want to set the value it is very similar and don't forget to objRecord.save()
thumbs up 1