Hello.
I’m trying to send information for a Label using the Scan Barcode (with def onBarcodeDataReceived(session, data, context) ).
I can pass information using Tag (system.tag.writeAsync(‘Writable/scantest’, vCamSerial)) but I would like to pass directly to the Label.
Button trigger onClick → Scan Barcode
Session Event:
def onBarcodeDataReceived(session, data, context)
SCRIPT.canCam([data.text])
Project Library:
def scanCam(vCamSerial):
#works but I don't want to use TAG
system.tag.writeAsync('Writable/scantest', vCamSerial)
#not works
self.getSibling("Label_0").props.text = vCamSerial
Thanks
The event is in the session, so it doesn’t have direct access to pages and views. Send a message at session scope. Have a handler on the label listening for session scope.
Is there some way to read a barcode (mobile onBarcodeDataReceived) to send the value without using TAG.
Yes, send a message to the label with system.perspective.sendMessage
.
1 Like
Thanks, I will take a look at this method, I didn’t use sendMessage yet.
Do you have an example? I am trying to get out user can not read codes from other users. is this the best way to use it?
Sorry for the late reply. 
This is how I did.
Button (Event):
OnActionPerformed:
def runAction(self, event):
Consult.ConsultMaterials.CleanConsult(self)
Script (Project library)
def scanCam(vCamSerial):
system.perspective.sendMessage(
'getBarcodeScanned'
,payload = {
'vSession':123
,'vLabelScanned':vCamSerial
}
,scope="session"
)
OnClick:
Scan Barcode
Script Message Handler: Label that will receive the scan info:
def onMessageReceived(self, payload):
#getBarcodeScanned -> Message Type
#Session, Page -> Listen Scopes
vSession = payload['vSession']
vLabelScanned = payload['vLabelScanned']
self.props.text = vLabelScanned
self.getSibling("tfConsLabelScan").props.text = vLabelScanned
Consult.ConsultMaterials.ConsultMaterial(self,vLabelScanned)