<@U5375UUJ2> Interesting! I have a ssv2 script tha...
# suitescript
k
@stalbert Interesting! I have a ssv2 script that fails every time and had to be replaced with an ssv1 version. When I talked to NetSuite Support they said that bank deposits simply aren't supported in 2.0
s
Also note I'm referring to the record type 'deposit' - there is no bank deposit that I'm aware of (though deposits are often to a bank account?)
I'm creating deposits like this in SS2:
Copy code
const d = new Deposit(undefined, undefined, { deposits: txList })
    d.account = DEPOSIT_ACCOUNT
    _.forEach(d.payment, p => p.deposit = true)
using the intializeValues because I need to create deposits with thousands of lines where there hundreds of thousands of candidate undeposited transactions
k
Where does Deposit() come from?
s
NFT
k
NFT?
s
actually, Deposit is a new record type not in a released version of NFT (yet). It's definition looks like this:
Deposit.ts
k
Cool thanks!
s
and I have confirmed that deposits indeed save successfully on this sandbox at least!
k
Awesome! I've got a similar use case for one of my scripts but have to use a 1.0 version as a fallback for this part of the process.
n
Just be warned, there is an issue with creating deposit records. I built a system for a customer that takes a CSV of transactions and matches them at line level on a deposit and creates the deposit. It has worked on thousands of records but every once in a while it errors with an error on the lines of "document is not defined". It doesn't matter if you define the transaction id's as you create the record or create the deposit then set individual lines. I have been in talks with support for a few weeks now and they know it's a defect and are working on it. It's currently an S2. It's inconsistent. I can run in a file and it fails and run it in a second time and it works...or not. Same code, same file, same transactions, spin the wheel. I can however also consistently reproduce the error in sandbox, doesn't matter if I work with the record in dynamic mode or not. When trying to troubleshoot this I found an article back in 2018 discussing it: https://netsuitehub.com/forums/topic/suitescript-2-0-server-side-code-is-referencing-the-document-object/ So just keep your eye on your code, it may start to fail.
Also, if you have multiple Accounts and multiple currencies you're going to want to make sure the account set on the deposit's currency matches the currency on the transaction, otherwise you'll error if you don't supply the correct currency value on the line.(I'm in the UK and my customer trades in USD / GBP / Euros)
k
@NElliott yeah that's basically what we're running into also, except we're using a custom record type generated from a CSV to do the actual matching. NetSuite Support basically says it's unsupported in 2.0 and to just use 1.0 instead.
@stalbert could you show me how that deposit creation works in context? It's unclear to me how the
d = new Deposit()
is used once you've initialized it. Do you just populate all the field values then do something like
d.save()
?
s
thanks @NElliott - I haven't seen that yet but at least it's an S2 severity. @Kris Wood yes, with NFT you work with all NS records just like any plain TS/JS object. NFT is a thin layer that calls getValue() etc. behind the scenes. There are several advantages to this, some of which is described in the readme.
that code snippet I shared earlier is the entire code. NFT results in elegant code by allowing direct use of established design patterns and libraries from the larger JS dev community. In that example, I used lodash to set the 'deposit' checkbox on all lines of the payment sublist as a single easy-to-understand line of code.
k
Cool, thanks again!