Hi, when creating Customer Payment via UI, there a...
# suitescript
s
Hi, when creating Customer Payment via UI, there are filter options available under Invoices/Credits sublist. I can apply filters and it will limit the results accordingly. Is there any possible way to achieve this in SuiteScript? I’m trying to overcome 10K line limit 😕
b
use the
invoices
default value
s
you mean when doing a record.create?
b
yes
s
just tried but it filters from the 10K results returned
b
what does your attempt look like
s
Copy code
let cp = record.create({
    type: 'customerpayment', 
    isDynamic: true, 
    defaultValues: {
        entity: 1437, 
        subsidiary: 12, 
        invoices: [956151, 1398892]
    }
});
b
are you sure invoice 956151 and 1398892 are valid options when the subsidiary is 12 and the entity is 1437
s
yes, both are
956151 is listed by default and 1398892 I can find in UI after applying a search filter
b
then you are doomed, that is the only known way to select which invoices appear in the apply list
s
I didn’t know the invoices option, thanks for the hint
b
so you better make extra sure that those are valid invoices and that you are properly checking the apply sublist
s
hm, when I pass a single invoice, it shows
seems the results are limited to a single invoice
b
probably want to take a closer look at the apply sublist
and the actual invoices in there
s
it always return 1 line for me, regardless number of invoices I pass
b
as in are you sure its the correct invoice in there
or is it the wrong one because you trust suitescript's ability to turn a number into a string
s
I tried using the first 2 invoice listed from the UI, again only one was returned
I also tried passing as string, same behavior
this will still help me to decrease the number of open invoices. thanks
b
did you actually need this in client script
or is your code supposed to be running serverside
s
it will run on serverside, to apply a journal to invoice
b
test the code serverside
s
just did, same behavior 🙂
b
pretty weird
the invoices default value is actually a string parameter
with the values from the array being converted into a csv
join the values yourself
s
but it is not officially documented, right?
b
its the same used in the ui
s
weird thing is record.transform does not work if the invoice is not within the first 10K being returned
b
there is a reason you want to get the invoices default value to work
it is the only known way to work
s
Copy code
let cp = record.create({
    type: 'customerpayment', 
    isDynamic: true, 
    defaultValues: {
        entity: 1437,
        subsidiary: 12,
        invoices: '1398892,956151'
    }
});
wow, this worked
previously I had unintended space after comma (coding bad practice 😄 ) which threw unexpected error
s
space after a comma is not bad practice. CSV parsing that can't handle spaces is bad practice.