Perspective Barcode Data Handling Script for Multiple tags

Hi, I’m trying to make an inventory tracking system and need multiple barcodes to scan them in and out of the closet. I already have the scan barcode button as well as 2 barcodes created. My problem is that no matter what barcode I scan, it writes the output to my first tag in my script. I need every barcode to write an output to a different tag. Can someone help me out?

The ‘barcode scanned’ event is generic - every barcode you scan will call in to the same event. You need to configure your ‘Scan Barcode’ action with additional “context”, which you then retrieve in the barcode event script and use to determine which tag to write to.

So I create context on my scan event then is this how I retrieve it in the barcode event script?

Wait, I’m leading you down the wrong path.

Re-reading your first post, it seems like you know what the values are going to be in these barcodes?

Yes I will be assigning the quantity of each item we have in inventory to each barcode corresponding to the item

Hi PGriffith, I still need assistance with this, when you get the chance.

What’s your desired flow, exactly?

Is it something like:

  • You’re in your inventory room.
  • You scan a barcode that’s physically in the room identifying a particular part.
  • You enter a count in your Perspective interface
  • The count is written to the appropriate tag

Or can you describe what you’re trying to do in more detail? The order of execution of events is important here, because it will dictate what you have access to when the barcode event fires.

This is the exact flow of events I’m looking for.

Okay. I’m going to assume the data that the barcode contains is something to identify which part you’re looking at.
So the first thing you’ll need, somewhere, is a mapping from part numbers to tag paths. At least from your screenshots, you have a bunch of numbered Quantity tags and nothing else.
So what you probably want to do is something like this:

  • Invoke your scan barcode action as you are. Don’t worry about ‘context’ or anything like that.
  • In the “Barcode Scanned” event hook, you’ll open a view that will hold the actual data entry. Pass this view a parameter - the actual part number that was scanned.
  • In the view, you’ll probably have at least three components:
    • a Label with the part number that’s coming in as a parameter
    • an input field for entering the part count
    • a submit button
  • The submit button will have a script that uses the part number and the mapping from above (a DB table or project library script or something similar) to determine which tag to write to, reads the value from the input, and writes back to that tag.

Hello PGriffith! thank you so much for your help! I have just one more question. I’m new to ignition and was wondering how do I differentiate between barcode scripts for various views? I’m currently trying to make a barcode login page where a barcode is scanned to identify the user and all items checked in and out are linked to whoever is logged in?

If you have different sources of the barcode action, that is where you could use the “context” field to differentiate. So you’d have a “login” context, and a “cycle count” context (or whatever other names you prefer). Then in the single barcode event handling script, you just immediately branch your logic, something like:

if context["context"] == "login":
    # do your login related barcode handling
elif context["context"] == "cycleCount":
    # do your cycle count barcode handling
1 Like