Hi everyone, I'm looking for the best practice in ...
# suitescript
n
Hi everyone, I'm looking for the best practice in SuiteScript 2.1 for a performance issue. The Challenge: I have a script that needs to apply a payment to a specific invoice for a customer with over 35,000 open invoices. The Problem: Creating a payment from the customer record using
record.create
or
record.transform
fails. Both methods try to load all open invoices into the
apply
sublist, which hits the ~10,000 record governance limit. This makes it impossible to find and apply the payment to the correct invoice if it's not in that first batch. Failed Attempts: • Loading the Payment: Fails due to the 10k limit. • Loading the Invoice: Fails due to a timing issue (the invoice doesn't "see" the newly created payment to apply it). What is the recommended architecture for this scenario? Thanks for your help!
a
why the hell do you have a customer with 35k open invoices?!!
n
Believe me, I ask myself the same question every day! But that's the client's business process, so we have to make it work. haha
g
Well I am sure glad I saw this question. Struggled with this for multiple use cases and ended up generating a CSV file and triggering and upload via a scheduled script to get around it. That is until I got this undocumented tidbit a while back. If you add the defaultValue->vendorbills, that will limit the apply sublist to only the records specified so you only get back what you want. If you have vendor credit just include those internal IDS as well. If you want to see it in action in the UI if you go to an existing payment hit edit and add &vendorbills=11111,22222 to the URL it'll narrow down apply in the UI too.
Copy code
record.create({
  type: record.Type.VENDOR_PAYMENT,
  defaultValues: {
    vendorbills: "11111,22222"
  }
});
ā˜ļø 1
šŸ”„ 3
a
that's cool, I had no idea you could set default values for things other than what's documented
n
Thanks I will try this now, I hope it works
e
Nice!
Thanks a lot for that reference @Geo
n
Thanks a lot @Geo it works
šŸŽ‰ 2
e
Wow, that's amazing. Had no idea. I just confirmed this works for invoices on customer payments as well. You can pass in "invoices" in the same way in the URL or in defaultValues. I've got some code that will be greatly simplified by this. Thank you!
g
@eblackey yep! I neglected to mention that does work as well. The only thing I haven't tested yet is if there is any limit to the number of records you can pass in or if any performance issues arise. Have one automation that runs Thursdays and does a CSV upload to create some bill payments but each payment is often applied to 1-3k records, not sure if that is within the use case