Marty Zigman - The NetSuite Expert

Conversations with Marty Zigman

Certified Administrator • ERP • SuiteCloud

Prolecto Labs Accelerator Templates

Learn the NetSuite SuiteScript 2.0 Pattern to Apply Customer Deposits to Invoices

NetSuite Technical



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?

Marty Zigman

Holding all three official certifications, Marty is regarded as the top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. He is a former Deloitte & Touche CPA and has held CTO roles. For over 30 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to set up a conversation.

More Posts - Website - Twitter - Facebook - LinkedIn - YouTube

About Marty Zigman

Marty Zigman

Holding all three official certifications, Marty is regarded as the top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. He is a former Deloitte & Touche CPA and has held CTO roles. For over 30 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to set up a conversation.

Biography • Website • X (Twitter) • Facebook • LinkedIn • YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *