Does anyone have experience with Custom Records sk...
# suitescript
d
Does anyone have experience with Custom Records skipping 100 internal id's after only a few records are created? Example: 1, 2, 3, 101, 102, 201, 202, 203, 204, 301
i personally suspect that netsuite internally reserves batches of internal ids (very common for webservices)
đź’Ż 3
s
I agree, it appears that ids are reserved in blocks of 100 (the pattern of ids we see supports that anyway). If sequence or stable ids are important, it is best to use external id or a custom field to set your sequence number. internal ids may not even be in the same sequence as transaction document numbers, for example, because blocks of ids are reserved for a script in advance, while the document numbers are assigned sequentially.
s
those (netsuite internal ids) are stable in the sense that they don't change and aren't reused. The main takeaway is one shouldn't make assumptions about the ids. NetSuite isn't 'skipping' numbers because there's no rule that says internal ids increment by one with each new record. One observation I've seen (still not a rule) is that netsuite internal ids can be viewd as monotonically increasing integers (even though apis return them as strings).
s
Right, however if you sort records by date created, the internal ids may not be sequential. We have this situation with a restlet that creates batches of up to 52 sales orders (due to governance limits). if the restlet is called again while the first call is still executing, the second group will have ids that start at a higher number than the ones used by the first script, but can be created before the first script finishes creating all of its records. That’s why NetSuite doesn’t guarantee that a higher internal id was created after a given record, nor that a lower internal id was created before. In a high volume system, or with concurrent calls, the internal ids are often not in the order the records were created.
Basically, you can’t infer any meaning from the internal id, it’s just a guaranteed unique id for that record type, and nothing more
s
exactly
that's a best practice (meaningless primary keys) so kudos to NS.
d
Ah I see, I am sending the internal id over to a second system. My concern was the length of the internal id rather than the sequence. That makes sense. Once the internal id gets high enough the length will take longer to expand so in time it will even out I guess.
Thank you all for the input and the link!