Nikita Petrov
12/02/2019, 5:58 PMvar recDepositApp = nlapiCreateRecord('depositapplication', {
recordmode: 'dynamic'
});
recDepositApp.setFieldValue('customer', customerId);
recDepositApp.setFieldValue('subsidiary', mySupsidiary);
recDepositApp.setFieldValue('aracct', accountsReceivableDirect);
recDepositApp.setFieldValue('postingperiod', 121); // November 2019
recDepositApp.setFieldValue('deposit', customerDeposit); // Customer's Deposit record
var applyLineCount = recDepositApp.getLineItemCount('apply');
var foundLine = 0;
for (var applyLine = 1; applyLine <= applyLineCount; applyLine += 1) {
recDepositApp.selectLineItem('apply', applyLine);
var lineType = recDepositApp.getCurrentLineItemValue('apply', 'type');
var lineRecordId = recDepositApp.getCurrentLineItemValue('apply', 'internalid');
if (lineType == 'Journal' && lineRecordId == jeId) {
var due = recDepositApp.getCurrentLineItemValue('apply', 'due');
nlapiLogExecution('DEBUG', 'SUCCESS', 'Found: ' + applyLine + ', applied:' + recDepositApp.getCurrentLineItemValue('apply', 'apply'));
recDepositApp.setCurrentLineItemValue('apply', 'apply', 'T');
recDepositApp.setCurrentLineItemValue('apply', 'amount', taxAmount);
recDepositApp.commitLineItem('apply');
nlapiLogExecution('DEBUG', 'NOT SUCCESS', 'Applied? ' + recDepositApp.getCurrentLineItemValue('apply', 'apply'));
foundLine = applyLine;
}
nlapiLogExecution('DEBUG', 'LINE', 'Line item: ' + lineRecordId);
}
var daId = nlapiSubmitRecord(recDepositApp);
nlapiLogExecution('DEBUG', 'Success', 'DA rec is created: ' + daId);
I'm getting the 'Found: 1, applied: F' message, so the system is able to list the Journal record I created for this customer, but the system is unable to change the 'apply' checkbox for it ('NOT SUCCESS Applied? F'). However, if I create the same DA record from Netsuite UI manually, I see that the checkbox for this line item is enabled and I can apply the DA record to it from UI.
Why I cannot apply it through the Suitescript?