Any reason to use one over the other if I am looki...
# suitescript
c
Any reason to use one over the other if I am looking to uniquely identify a line item?
b
line is unique within a certain transaction, line unique key is unique among all transactions
one is more unique than the other
though line tends to be more common when finding related lines between different transactions via the suitescript record model
m
depends what you want to use it for - if you want to build a unique key that is visible to the end user (we had such a case last month), you need to take into account that
lineuniquekey
is a number such as 54883900 and can easily jump with hundreds; as battk says, if you want "uniqueness" within the transaction, just use `line`; if you need it among all transactions, use either
lineuniquekey
or
transaction id + '-' + line
c
I've always used line - looks like that was the correct choice.
Thanks!
r
What would be the best way to go if you would like to identify a given line across multiple transactions? For example, a given line in the PO, that will also appear in the item receipt and in the bill (once the PO is transform). Not sure if 'line' will fit this purpose, as I wonder whether there is an use case where, in a PO, line '2' could be line '3' in the bill. I have check 'lineuniquekey' but I see is fully unique, so it is not replicated in other transactions that come from that first one.
b
make your own custom column, and set up the column to apply to the transactions you want linked
give each column your own unique value
depending on how your account is setup, be prepared for unusual cases where some items can appear on some transactions and not others
like kit item members that require inventory details
r
that's an interesting solution. So I presume the custom column with the unique value should be created at PO creation. How would you create it to guarantee the uniqueness of the value to be set in the column? Do you think is feasible to just try to map the lines with a combination of matching values that are present in the order already? As the above solution might get a little tricky because of the mention case and maybe some others
b
depends on your requirements for the id
uuid is usually a safe bet
👍 1
i personally like creating a custom record and setting it as the value of a select field on the line
its how you can get line level exports without modifying the parent transaction, which preserves last modified dates and doesnt do a transaction load/save to store integration information
r
what do you mean with line level exports? In my case it would be a custom record that contains no field, so only the automatically added id. Am I right? Still I would like to avoid this path and try what we discuss in the other thread, as I believe is the case that you are referring, only one level away from the parent
b
typical integration technique for sending data out of netsuite is to mark a checkbox to indicate it was successfully exported
sending only some sublist lines instead of others requires a line level checkbox
which can be a fairly slow update to update the checkboxes, especially if there are other customizations
is especially inappropriate if you have to support updates
using a custom record that is associated with a line allows you to store the checkbox on the custom record instead of the line
r
ah, that makes sense, seems like the best way to go for that kind of cases. In my case, I will try to make it work with the orderline. If not, I think I will resort to the custom record creation per line, using the id assigned by NS, so I do not need to think about the uuid creation
s
I use a monotonically increasing integer for unique line identification.
r
How do know the last number that was use? I believe what you are saying is that what you use is not a custom record, but simply an integer in the line of a given transaction.
s
yes, IIRC I add a user event on the originating transaction to set the next value
The code may need some tweaking as I think there might have been an edge case not accounted for. I don't recall, but I know this worked for the actual use cases encountered at the time, including things like deleting lines from the originating transaction, ensuring the custom line number isn't reused.
r
Very interesting, thanks for sharing! I definitely see a lot of value having a custom unique line identification in parent transaction that you can track in child transactions
s
yup, while NS provides it in some transaction chains, there's nothing that spans all combinations.
b
oh hey, its supports removed lines now, thats improved from the last time i saw that code
this version looks much more typescripty than the last time too
s
my bad 🙂