Anyone has any tips regarding setting the column a...
# suitescript
w
Anyone has any tips regarding setting the column account to an account-type on the sublist allocationsource on allocationschedule?
b
share the code
w
var newrec = nlapiCreateRecord('allocationschedule');
newrec.setFieldValue('name','testrecord1');
newrec.setFieldValue('frequency','MONTHLY');
newrec.setFieldValue('creditaccount',1);
newrec.setFieldValue('weightsinpercentage','T');
newrec.selectNewLineItem('allocationdestination');
newrec.setCurrentLineItemValue('allocationdestination','account',1);
newrec.setCurrentLineItemValue('allocationdestination','weight','100');
newrec.commitLineItem('allocationdestination');
newrec.selectNewLineItem('allocationsource');
newrec.setCurrentLineItemValue('allocationsource','account','OthIncome');
newrec.commitLineItem('allocationsource');
nlapiSubmitRecord(newrec);
This will result in "Invalid account reference key OthIncome for accountingbook <NULL>.". This is probably due to Netsuite trying to translate the value to an account, not an accounttype. Maybe there are some magic internalids (numeric) even for the accounttypes?
b
use
Copy code
newrec
      .getLineItemField("allocationsource", "account", 1)
      .getSelectOptions()
to get an array of nlobjSelectOptions
check for your id in there, if its not there, you usually are gonna have problems trying to set that id
if it is there, you probably want to try netsuite support
a desperation option might be to try using newrec.setCurrentLineItemText with the text of the option
w
Thanks, unfortunately getting the id of the select-options gives me the internalId's of accounttypes. (OthIncome,Equity,Income,Bank). But those are the ones that I cannot set.
I've also tried using setCurrentLineItemText() but that gives me a record that don't have a value in 'account' but have '< >' in 'account_display'
I've created a case towards Netsuite. We'll see if they have anything to say.