Hi everybody, I have an issue with creating a Depo...
# suitescript
n
Hi everybody, I have an issue with creating a Deposit Application record - I'm unable to apply it to a transaction, can somebody help me please? I'm getting an error 'System USER_ERROR You must enter at least one line item for this transaction.' Here is code for creating DA record:
Copy code
var 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?