I am trying to use the barcode scanner to go to different views based on different codes that the app scans.
The idea is to have QR codes on different pieces of equipment and when someone scans the code it will go to a view and display information.
ie. scan a pump and show a view with pump attributes. scan a vessel and it would show vessel attributes.
I tried using "system.perspective.navigate" in the barcode script handler but it did not work.
I was hoping someone could point me in the right direction to move forward.
Thanks
I would try a message. Under the Barcode Session Event, parse the barcode and send a message. I did it like this for a popup(the custom session prop is probably not needed):
def onBarcodeDataReceived(session, data, context):
tag = data.get("text", "no data found")
session.custom.barcode = tag
params = {"tag":tag}
view = "Popups/Pump"
messageType = "PumpPopup"
payload = [tag]
scope = "session"
sessionID = session.props.id
pageID = "Barcode/LandingPage"
system.perspective.sendMessage(messageType, payload, scope, sessionID, pageID)
On the page that you are calling the barcode scan from, in the root container create a Message Handler like this:
For yourself you would use the system.perspective.navigate instead of .openPopup. The payload would contain the destination. I highly recommend first passing the entire barcode data to a text field so that you can see how it actually arrives. This way you can parse it properly before sending the message.
2 Likes
Don't forget to hit the "Solution" button on the post that solved your problem.