Need help accessing barcode data in a mobile app
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
I am creating a custom mobile app that allows the user to scan multiple asset barcodes before submitting. The function that submits the data is a scripted Action Item that uses a WriteBackAction to run a function in a script include.
My problem is the barcode data, it's not sending the type of data I thought it would be. I watched the Mobile App Academy video for QR Code scanning several times, and in it the presenter says the data is just a string, but that's not my experience.
Once I scan multiple barcodes and submit, the script log shows it is "Ljava.lang.string:@xxxx". How do I pass the scanned data to a script include?
My mobile Action item WriteBackAction:
The messages take the "else" path, I do have a sys_id and scanned assets data.
Currently my script include function is simple:
Where did I go wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
53m ago - last edited 51m ago
Hi @gjz ,
Please follow the below suggestion :
Convert the Java array to a standard JavaScript string using String(assets) or "" + assets, then split it into an array:
In your script include : change the below line
updateAssetScanData: function(assets, recordID) {
var scanID = recordID;
// Convert Java object to a JavaScript string and split into an array
var assetList = assets ? String(assets).split(',') : [];
gs.log('@@ record id: ' + scanID);
gs.log('@@ Scanned Assets: ' + assetList.join(', '));
}
Check: verify your syslog after scanning. It may display readable barcode strings .
Please mark helpful & correct answer if it's worthy for you.
