We are trying to use a script to apply a payment t...
# suitescript
c
We are trying to use a script to apply a payment to a customer that might have more than 10,000 open invoices. We are seeing that the {apply} sublist is limited to only 10,000 invoices, which seems to be a NetSuite limitation. Has anyone had similar issues with sublists exceeding 10,000 results? If so, do you have any suggestions for how you were able to work around the limitation?
🤮 2
👀 3
b
Lookup customer payments on the suitescript supported records help page for an example on using defaultValues
a
Well I see two main problems with this: 1- I’m not an accountant but I would think that paying more than 10k invoices with only one payment is not a good accounting practice in any way, shape or form. 2- You will have a very very hard time if you ever need to edit that payment for whatever reason or even just visualize it in the UI.
j
@battk I'm struggling to find the page you are speaking about, on the Customer Payment page I can find it says you can't create them via suitescript and that's definitely not the case.
b
well thats weird, i could of sworn it used to have an example of how to specify which transactions you want to apply the customer payment to
and a bunch of stuff about filtering the list
j
I wonder if it's been moved/removed, I've tried to apply the filters in dynamic mode before and didn't manage so was hoping there would be a way with default values. On the default values page entity is the only one specified.
c
It looks like you can apply the filter by invoices using 1.0… but not 2.0. At least it is specified that way in the help section.
b
its very sad, i only remember the inv parameter can be used to specify which invoice you wish to pay
c
it is frustrating that there is functionality like this that was not included in the newer API’s.
b
you can use inv in ss2
c
thanks… i’ll try it and see
b
i think it only works with 1 invoice at a time
you also might be able to do something like
Copy code
require(["N/record"], function(record) {
  var payment = record.create({
    type: record.Type.CUSTOMER_PAYMENT,
    defaultValues: { entity: '9', invoices: "110,171" }
  });
  for (var i = 0; i < payment.getLineCount({ sublistId: "apply" }); i++) {
    payment.setSublistValue({
      sublistId: "apply",
      fieldId: "apply",
      value: true,
      line: i
    });
  }
  payment.save();
});
to choose which invoices appear on the apply list
c
adding that change to my code right now, I’ll keep you updated. Thanks for the help