How to access component from Session barcode script

I am creating this application that will read a barcode and write the barcode to a tag and a numeric entry field component. The user will click the "Scan Barcode" button and and the camera will come up (this is using the perspective app so it works) then this session script will take the dat and I got it working to write to the tag. However I don't know how to access components from the session itself.

image

image

There is no way to reference the component from within the Session script, because the script is in no way tied to a component. What you should look at instead is passing along important information through the context object you can supply within the Scan Barcode Action you're using to set this Event up.

After re-reading your original question, I think you're performing some questionable setup here:

  1. Any session will be able to write to that tag.
  2. If you're only trying to display the tag's value to the user, consider using a Label instead, and just bind the Label's text to the tag value.
  3. If you Do need the user to be able to edit the scanned value, then continue using a Numeric Entry Field, and just bi-directionally bind the value of the component to the tag.

If individual sessions need independent display values, consider using a session custom property as your write target within the session event. Bind your label to that session custom property. For more complex cases, consider re-broadcasting the event as a message, using the context information in message handlers to filter to the relevant component.

1 Like