Ok so as a follow up to my last question. I have a...
# suitescript
f
Ok so as a follow up to my last question. I have a customer that is trying to create a Bill Payment via SuiteScript 2.0. However the vendor has more then 10,000 Open bills. Even when using record.transform to transform the bill directly into a Vendor payment when I try to save that payment I get:
You must enter at least one line item for this transaction.
anyone has any other idea how to create a vendor payment for vendors that have thousands of open bills? and obviously calls like
findSublistLineWithValue
fail to find the line item
a
For
Bill Payments
and
Customer Payments
with many lines
findSublistLineWithValue
is not going to work or find a line buried deep into that huge sublist. There is a way to use defaultValues when doing the transform to select the required open bills, but I don't remember from the top of my head.
There are two options no very well documented: • defaultValues: { account: '2', disablepaymentfilters: true } • defaultValues: { 'deposits': '818,819' } From: suitescriptrecordsguide.pdf Page 124.
f
where do you get that pdf?
can't find it in SuiteAnswers
w
Copy code
url.resolveRecord({
                recordType: record.Type.VENDOR_PAYMENT,
                recordId: '',
                isEditMode: true,
                params: {
                    entity: entity,
                    bill: billId,
                    subsidiary: subsidiary,
                },
            });
Above works for a url, perhaps “bill” also works as a defaultValue?
a
@fkrauthan You would find that PDF in the Help, Help != SuiteAnswers
f
Never mind found it
But does
disablepaymentfilters
work for VENDOR_PAYMENTS as well the doc just says for DEPOSIT. Also it doesn't explain how to select the bill (or bills in some cases in case of batch payment) without using
findSublistLineWithValue
a
You are going to find not documented stuff in NetSuite all the time, you need to try and test stuff…specially when you hit this types of walls… Not everything is documented or properly documented, there is a lot of trash code in SuiteAnswers for example…
f
True that
ok that flag does not work for vendor payments
Copy code
You have entered an invalid default value for this record initialize operation.
b
same answer as the last time you asked, use the
bill
or
vendorbills
default values
in general, default values are the same as those used in the query parameters of urls
f
Yeah I did but it didn't resolve the issue if someone has more then 10,000 bills for that vendor 🙂 at least I couldn't find anything for it. And it seems the apply list on UI can have different sorting which makes different range of the more then 10,000 bills available then what I can do via code
b
what did your attempt look like
f
I even tried just using Bill => Vendor Payment transform but that e.g. showed
Copy code
You must enter at least one line item for this transaction.
(see initial message)
I also tried to use non dynamic mode (for transform as well as record.create with defaultValues) and then
findSublistLineWithValue
but they all turned out with return
-1
b
code
f
Copy code
const vendorPayment = record.transform({
      fromType: record.Type[type],
      fromId: billIds[0].billId,
      toType: record.Type.VENDOR_PAYMENT,
      isDynamic: false,
    });
    vendorPayment.setValue({
      fieldId: "account",
      value: sourceAccount,
    });
and then
Copy code
const lineItem = vendorPayment.findSublistLineWithValue({
      sublistId: "apply",
      fieldId: "internalid",
      value: billId,
    });
(in case I have more then that single bill id)
b
if you have more than one bill, then you cant use transform
nor can you the bill default value
both of those are single bills
leaving you the third option i gave you
f
No it does work for multiple bills too
just not if the vendor has that many bills
b
correct, it works sometimes
f
But even in case of a single bill the transform errors
after submitting the payment (no call to
findSublistLineWithValue
involved
b
make the payment in the ui first, set the same fields that you set in the ui
there are occasionally things like currency that needs to be set
f
Yeah I know and I did. And depending on how I sort the apply list I can select the payment or I can not select the payment
but I can't change order through code
b
if you are trying to select in code
its too late
the limitations of the sublist will screw you
f
ok yeah that was the answer I was looking for
or if I missed something
b
so you either learn to use the
vendorbills
default value, or settle with code that sometimes work
✔️ 1
w
@battk what is the syntax for using the
vendorbills
defaultValue?
b
try it out in the ui first
w
I tested vendorbills: "xxxxxx,yyyyy" and it then gave me a record where those bills were the only ones available in the sublist, so I figure you use that defaultValue to "filter" the list and then loop through and apply them?
b
correct
w
I am curious how it would handle it if I supply it with bill(s) that are not in the primary currency for the vendor. I can't seem to default the currency, I've tried with cu/curr/cur/currency/trancur. Is there an undocumented defaultValue for that as well? 😄
I'll test it
b
none for currency, you are forced into using dynamic mode
w
It doesn't automatically set the currency from the first bill in
vendorbills
?
...nope.
But the filtering is kept in the UI at least, so if you change the currency to the correct one, only the ones that were in the
vendorbills
are shown. Nice to learn new tricks for the future if needed. Thanks!