While using FindSublistLineWithValue, for few reco...
# suitescript
r
While using FindSublistLineWithValue, for few records it works on the deposit record and for few records it returns -1 even the record is there. Any idea
s
I use
_.find(record.sublist, l => l.somefield == 'value')
i.e. I don't generally use
findSublistLinewithValue()
r
@stalbert did not get you
s
I use NFT and lodash
_.find()
to find a sublist line, which gives me the line object I can then manipulate directly.
r
got it. Thanks
s
I don't recall any issues with it behaving erratically as you're describing FindSublistLineWithValue
r
I have around 2000 cash sale and cash refund and I am creating a deposit record using Suitescript. For 1700 records this works fine but for remaining 300 it is returning -1 but when I create a deposit manually, I can search 300 records there
s
I've actually done similar, but I don't use _.find() at all - not sure why you are but I'd recommend looking into initializing the deposit record at record create time (standard mode)
r
I am tried both with Dynamic and Standard
Standard means Static but same issue
b
how may lines are on the desposit
s
I initialize the deposit like so:
const d = new Deposit(undefined, undefined, { deposits: txList })
where
txList
is an array of transaction internal ids
r
around 2000
s
I know the approach I describe works well for up to 10,000 lines (which IIRC is the maximum supported by NS)
I have to split multiples of 10,000 across deposits.
b
are there different amount of lines in the script record vs the ui?
r
no
how do you split
s
I split by running the large output (100k+) search result set lazily through
reduce()
and let the accumulator keep accumulating up to 10,000 then write out the deposit, then simply reset the accumulator and the reduce() continues to iterate, building up (accumulating) transactions for the next deposit, and so on.
this is in a scheduled script in my case
since I really just need to iterate once over the entire result set, in order, creating an ordered (small) set of deposits. So it's large number in, small number out in my case.
it's elegant because the main iteration is lazy, consuming constant memory (1 page of results) regardless of how many total results need to be processed.
b
my general recommendation is Specifying Payment IDs
you can try sharing your code and some values that are causing problems
but the brute force way is to simply find the matching line yourself
r
@stalbert you are right. It is 10k limitation. I created one deposit of 10k entries and now my script can find the entries
@stalbert how do you load all the entries for deposit record in your code?
@battk
Copy code
deposit.setSublistValue({
        sublistId: 'payment',
        fieldId: 'id',
        line: 1,
        value: cashSaleId
    });
I need to find the line number in my code using FindSublistLineWithValue
b
that is weird, im not sure why you would be attempting to set the id
r
@battk this code is from the link you shared
b
i called out the Specifying Payment IDs section
s
yes, he's given you the official documentation on the method I lamely pasted above
this needs some cleanup but the gist of it is
get_Eligible_transactions_just_runs_a_lazy_search_.ts
r
@stalbert @battk Thanks