This article is relevant if you need to see a NetSuite SuiteScript 2.0 code snippet for how to apply a customer deposit record to an invoice.
Background
In my article, Use NetSuite SuiteScript to Automate Posting Customer Deposits to Invoices, I offered a SuiteScript 1.0 pattern to apply customer deposit amounts to invoices. These days, we are working in SuiteScript 2.0. So here is the related code pattern.
NetSuite SuiteScript 2.0 Apply Customer Deposits to Open Invoices
Here is the code snippet developed by one of our consultants working an application to apply unlinked customer deposits to an invoice.
//code snippet to apply a customer deposit to an open invoice var rcdDepositApplication = record.transform({ fromType: record.Type.CUSTOMER_DEPOSIT, fromId:CustDepositId, toType: record.Type.DEPOSIT_APPLICATION, isDynamic: true }); rcdDepositApplication.setValue('trandate' , new Date()); rcdDepositApplication.setValue('memo' , 'Created via the utility on ' + new Date()); //loop the lines and find the InvoiceId (code not shown) to apply funds: assumption is that we are applying //the total amount due var nbrLines = rcdDepositApplication.getLineCount({ sublistId: 'apply' }); for (var ix = 0; ix < nbrLines; ix++){ var sublistInvoiceId = rcdDepositApplication.getSublistValue({ sublistId:'apply' ,fieldId:'internalid' ,line:ix }); if ( sublistInvoiceId == InvoiceId ){ var SublistDue = rcdDepositApplication.getSublistValue({ sublistId:'apply' ,fieldId:'due' ,line:ix }); rcdDepositApplication.selectLine({ sublistId:'apply' ,line:ix }); rcdDepositApplication.setCurrentSublistValue({ sublistId:'apply' ,fieldId:'amount' ,value:SublistDue ,ignoreFieldChange:false}); rcdDepositApplication.setCurrentSublistValue({ sublistId:'apply' ,fieldId:'apply' ,value:true ,ignoreFieldChange:false}); } } rcdDepositApplication.save();
Be Appreciated for Your Capacity to Innovate
If you feel you hold high standards for care and you want to be appreciated for your ability to design, craft and build NetSuite solutions, perhaps it makes sense to have a conversation about career opportunities?