Hi, I was trying to populate a sublist during page...
# suitescript
t
Hi, I was trying to populate a sublist during page init. But however, it seems I can only get the first 2 field correct. Which is the "check" and "account" column. Also, I can only add one row, I was hoping that if the linecount is greater than 1, I can also create a new line item.
Here are the columns
nvm I found the solution 🙂 Here is a snippet, if you want to initially set field values on your sublist using client script and search
Copy code
var accountLength = accounts.length;// nlapiGetLineItemCount("itembudgetsublists");

if (accountLength && accountLength > 0) {
    for (var i = 0; i < accountLength; i++) {

        // console.log('accounts[i]=' + accounts[i] + ' accountTypes[i]=' + accountTypes[i] + ' monthlyavg[i]=' + monthlyavg[i]);
        nlapiSetCurrentLineItemValue("inputsublist", "check", true);
        nlapiSetCurrentLineItemValue("inputsublist", "custpage_account", accounts[i]);
        nlapiSetCurrentLineItemValue("inputsublist", "custpage_account_type", accountTypes[i], false, true);
        nlapiSetCurrentLineItemValue("inputsublist", "custpage_monthly_avg", parseFloat(monthlyavg[i]), false, true);
        nlapiCommitLineItem('inputsublist');

    }
}