Monday, 12 August 2019 14:37

Access more than 10.000 records in a sublist

Written by

Filtering invoices on Customer Payments in SuiteScript

This article will help you in the following scenario: You have a customer with a very high number of invoices open and there is a need to create a payment with some of them applied to. E.g. in an EDI environment.

 

When you try to do it in the NetSuite UI

 
you will see that on the apply sublist only 10.000 records are displayed and this is not a coincidence. NetSuite is limiting sublist to have only first 10.000 records displayed even if you have more transactions in it.
 
 
You can try to solve the problem by using date filters or change the sorting order - it is not a very handy solution, but still you can find the ones you need.

 

But what if you need to create a payment in a script?

 
Normally to create a payment for a customer you will use:
 
var payment = nlapiTransformRecord('customer', customerId, 'customerpayment');
...
var id = nlapiSubmitRecord(payment);
 
Unfortunately it won't allow you to filter data in the sublist, so if you try to apply transactions which are not in the first 10.000 lines script will not find them.
 
The solution for it is partially described in NetSuite help - unfortunately it is only available for nlapiCreateRecord() ( not for nlapiTransformReord() ) which takes initializeValues as a second parameter and for Customer Payment we have the following options:
 
Which means that our code should look like this:
 
 
var payment = nlapiCreateRecord('customerpayment', {
                entity: customerId,
                invoices: invoices,
 });
...
var id = nlapiSubmitRecord(payment);
 
... where invoices is a comma seperated list of internal ids of transaction which we want to have displayed on the apply sublist.
 
What if we also want to manipulate the sublists credits and deposits? Well, officially there is no way, but unofficially there are two more initialise values we could use 'credits' and 'deposits'
 
 
var payment = nlapiCreateRecord('customerpayment', {
                entity: customerId,
                credits: credits,
                deposits: deposits,
                invoices: invoices,
});
 
They work in the same way - string with comma separated list of internal ids of transaction.
 
Thanks to them you will be able to bypass the 10.000 records limit on a sublists and book your payments automatically.
Read 1296 times Last modified on Friday, 16 August 2019 14:42

Latest from Lukasz Kubasiewicz

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.

CONTACT US!

O NetSuite SuiteCloudDeveloperNetwork rgb 2NetSuite SolutionProvider horiz rgb

NOTE! This site uses cookies and similar technologies.

If you not change browser settings, you agree to it.

I understand