Hi all, I have created a Suitelet with a custom fo...
# suitescript
h
Hi all, I have created a Suitelet with a custom form. Now I want to sum the amount of all the applied lines using a Client Script. When I try to get the amount value from the sublist it returns undefined. The only sublist value I can retrieve is if the Apply checkbox that is marked (returns true). All of the other columns return undefined. Does anyone have an idea of how to get the values from a custom sublist columns? I have tried using both sublistChanged and fieldChanged but end up with the same problem.
function sublistChanged(context) {
var rec = currentRecord.get()
var sublistName = context.sublistId
if (sublistName === 'custpage_sublist') {
var lines = rec.getLineCount({ sublistId: 'custpage_sublist' })
for (var i = 0; i < lines; i++) {
var lineNum = rec.selectLine({
sublistId: sublistName,
line: i
});
var appliedCheckboxIsMarked = rec.getCurrentSublistValue({
sublistId: sublistName,
fieldId: 'custpage_sub_apply'
});
console.log('appliedCheckboxIsMarked', appliedCheckboxIsMarked)
console.log(i)
if (appliedCheckboxIsMarked) {
var amount = parseFloat(rec.getCurrentSublistValue({
sublistId: sublistName,
fieldId: 'custpage_sub_amount'
}));
console.log('amount value', amount)
}
if (appliedCheckboxIsMarked) {
var sublistAmount = rec.getCurrentSublistValue({
sublistId: sublistName,
fieldId: 'custpage_sub_amount'
});
console.log('amount without parse', sublistAmount)
}
}
}
}
b
what doe the suitelet code that creates the sublist look like
h
var form = serverWidget.createForm({
   
title : 'Confirm In-Transit Bill Payments'
 
})
// Sublist to list in-transit Vendor Payment
var subList = form.addSublist({
  
id : 'custpage_sublist',
  
type : serverWidget.SublistType.LIST,
  
label : 'Bill Payments with status: In-Transit'
})
 
subList.addField({
   
id : 'custpage_sub_amount',
   
type : serverWidget.FieldType.FLOAT,
   
label : 'AMOUNT'
   
})
// Gets Amount from search result 
var amount = result.getValue({ name: 'amount', join: 	'appliedToTransaction'})
// Adds it to the sublist 
subList.setSublistValue({
  
id: 'custpage_sub_amount',
  
line: i,
  
value: amount
 
})
b
probably want to use CurrentRecord.getSublistValue
the alternative is to make your amount column editable
h
thanks!