# Serial Number checks

**URL:** <https://forum.inductiveautomation.com/t/serial-number-checks/114787>\
**Category:** Ignition\
**Tags:** database, ignition81, scripting, perspective\
**Created:** [March 31, 2026, 1:45am UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787 "2026-03-31T01:45:22Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [March 31, 2026, 1:45am UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/1 "2026-03-31T01:45:22Z")

</div>

I have a system that goes through about 30 serial numbers per batch, at the current time the operator is scanning in the serial numbers into the system. To prevent duplicate serial numbers from being scanned, I want to track the serial numbers that have been entered and if a duplicate is scanned, display something on the screen.

I am debating using a document tag and storing the serial numbers in a JSON format. I was thinking it would be a quick tag write as the serial number tag changed and then I could just read the document values and see if the serial number was there. It would be easy to clear at the end of the batch too. I could also just store them as an array.

I also thought about using a database but I don’t need to keep them after the batch is done so I felt this was a good but unnecessary storage.

Does anyone have any suggestions or pushes to get me off the paralysis from analysis stage! thanks

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [March 31, 2026, 2:19am UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/2 "2026-03-31T02:19:03Z")

</div>

Others will know better but you could also use a dataset tag for this. Not sure if it's more efficient than JSON in a document tag though.

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [March 31, 2026, 3:07am UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/3 "2026-03-31T03:07:46Z")

</div>

We have used this with datasets, JSON seems to be heavier on the gateway due to the inefficiencies of string operations.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 31, 2026, 6:13am UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/4 "2026-03-31T06:13:16Z")

</div>

Document tags internal form is not JSON, and should be relatively efficient. Particularly if you are using the serial numbers as **keys** in your document.

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [March 31, 2026, 12:27pm UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/5 "2026-03-31T12:27:27Z")

</div>

i was going to use integers as the keys and the serial numbers as the value but I can reverse it. Would you recommend using the document tag over a dataset tag? Thanks!

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [March 31, 2026, 12:30pm UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/6 "2026-03-31T12:30:42Z")

</div>

> [@drewdin](#):
>
> Would you recommend using the document tag over a dataset tag?

For this, I would.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 31, 2026, 5:34pm UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/7 "2026-03-31T17:34:19Z")

</div>

My seat-of-my-pants rule of thumb:

\<=100 keys, sure, use a document.  
Up to ~1000-10000 rows, use a dataset.  
\>=10000 values, use a real database.

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [March 31, 2026, 6:56pm UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/8 "2026-03-31T18:56:58Z")

</div>

is there a faster way than system.tag.readBlocking, then looping the result to get the json?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [March 31, 2026, 7:36pm UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/9 "2026-03-31T19:36:03Z")

</div>

In a document tag it works like a dictionary. To test for an existing serial (assuming they are used as keys), the `.get()` method returns a fallback value:  
`if serialDoc.get(serialNumber, None) is None:`  
or  
`if serialNumber not in serialDoc.keys()`:

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [March 31, 2026, 8:01pm UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/10 "2026-03-31T20:01:04Z")

</div>

Thanks, looks like I still have to use a readBlocking to get the value and a DICT to convert it. I was hoping there was some super fancy way to just get the JSON from the tag without doing the tag read and parse.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [March 31, 2026, 8:16pm UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/11 "2026-03-31T20:16:14Z")

</div>

> [@drewdin](#):
>
> and a DICT to convert it.

I didn't have to do that under 8.3.1. What version are you working with?

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [March 31, 2026, 8:26pm UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/12 "2026-03-31T20:26:06Z")

</div>

I’m still using 8.1.44

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 31, 2026, 8:40pm UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/13 "2026-03-31T20:40:21Z")

</div>

If it's a document tag you should be directly able to work with it after a read. As in:

```python
doc = system.tag.readBlocking(["path/to/docTag"])[0].value
someValue = doc.get("someKey")

```

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [March 31, 2026, 9:03pm UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/14 "2026-03-31T21:03:19Z")

</div>

That worked for me, not sure why it was throwing an error before. It said unicode object has no function get when it was an empty dict

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [March 31, 2026, 9:17pm UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/15 "2026-03-31T21:17:53Z")

</div>

I did notice there is no len() function and I cant add items with myjson[‘newKey’] = ‘myval’ without making it a dict. I guess that makes sense as its a doc, not a dict? Thanks

---

<div class="post-metadata">

**Author:** ![hunterdg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hunterdg/32/67774_2.png) [@hunterdg](https://forum.inductiveautomation.com/u/hunterdg)\
**Post date:** [March 31, 2026, 10:00pm UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/16 "2026-03-31T22:00:27Z")

</div>

if this can be implemented in a view, consider a standard tag binding on a prop to the document tag (or part of it) like `[default]myDocumentTag['sub-object.deep-object.key']` - [Tag Paths | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.3/platform/tags/tag-paths#document-type-tag-paths)

can then parse the param via script or expression transform (lookup perhaps?)

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [March 31, 2026, 11:52pm UTC](https://forum.inductiveautomation.com/t/serial-number-checks/114787/17 "2026-03-31T23:52:20Z")

</div>

I’m using gateway scripts right now but I’ll keep that in mind for any views. thanks
