Scan QR code and populate details in a form

Hi

I am using ODK collect to scan a QR code. I created a form that uses barcode to scan. issue is an xml is getting created, is there a way i can get the values populated in a form. can someone provide me a sample form. I am using motoe3 power and odk collect v1.16.1

You are using a barcode type question?
The value populated in the form will depend on the QR code and not ODK.
For instance, I used https://www.qr-code-generator.com/#text to create codes for
doge and danbjoseph
doge    danbjoseph

I'm not sure I understand your note about:

an xml is getting created

Can you give more details about your question?

Thanks for reply. when i scan the QRcode, the output is displaying as an xml. how to get this xml populated into some labels like name,date of birth etc.

What is the XML that you are getting? Or better yet, can you perhaps just post the QR code. I suspect its simply the fact the QR code you are scanning has 'encoded' a string that just happens to be XML in the first place, in which case there's no a whole lot Collect can do about it... AFAIK the barcode widget doesn't subsequently try to parse the string/text it captured to determine whether its XML, JSON, YAML... and decipher it further.

Are you trying to pull out values from a QR code and assign them to different fields?

One way to do this is to separate the values in the QR code with spaces and to use the selected function. Take a look at the second form posted at Steps of printing barcode and auto fill the for by scanning barcode and continue updating another form - #9 by LN for an example. You should be able to try it out with the barcode provided in the message and see whether it's what you're looking for.

3 Likes

Hi, I know this is a old post but could you just confirm if you could use a different character to separate the text, like _ (underscore) or -??? Does it have to be a space?

selected() function requires space separated string.

[see https://github.com/opendatakit/javarosa/blob/master/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java line 1018 for the gory details...]

1 Like