SelectLine is not working with isDynamic:true . ...
# suitescript
s
SelectLine is not working with isDynamic:true . In the below code : the debug for account, amount , taxcode returned empty , also i could not set values on the same line for taxcode, whttax etc as it errors out asking to set the mandatory line field values. I think the code is not picking the correct line , rather picking the next empty line (ps : lineIndex used in selectLine is correct ) Code :
var *vbRec* =  record.load({
type:'vendorbill',
id:recId,
isDynamic:true
});
var lineIndex = vbRec.findSublistLineWithValue({
sublistId: 'expense',
fieldId: 'line',
value: lineNumber
});
log.debug('Line index',lineIndex);
var lineNum = vbRec.selectLine({
sublistId: 'item',
line: lineIndex
});
var account = vbRec.getSublistValue({
sublistId:'expense',
fieldId:'account',
line:lineIndex
});
var amount = vbRec.getSublistValue({
sublistId:'expense',
fieldId:'amount',
line:lineIndex
});
var taxcode = vbRec.getSublistValue({
sublistId:'expense',
fieldId:'taxcode',
line:lineIndex
});
log.debug('account,amount,taxcode',account+','+amount+','+taxcode);
vbRec.setCurrentSublistValue({
sublistId:'expense',
fieldId:'taxcode',
value:taxcode
//    line:lineIndex
});
vbRec.setCurrentSublistValue({
sublistId:'expense',
fieldId:'custcol_4601_witaxapplies',
value:true
//    line:lineIndex
});
vbRec.setCurrentSublistValue({
sublistId:'expense',
fieldId:'custcol_4601_witaxcode_exp',
value:whtCodeId
//  line:lineIndex
});
log.debug('values set','wht values set');
vbRec.commitLine({
sublistId: 'expense'
});
var *recId* = vbRec.save({
enableSourcing: true,
ignoreMandatoryFields: true
});
Let me know what am i missing here ! .
e
selectLine() is correct for dynamic mode. To select a value, you need to use getCurrentSublistValue(). getSublistValue() is used for static mode. The help page for the N/record module should have the info you need.
b
you arent actually selecting a line on the expense sublist
you instead selected a line on the item sublist
☝️ 1
so make sure you arent actually mixing up the expense and item sublists
s
Thanks. thats so silly of me . it worked