Storing QR code value from scanner into a temporary variable

Hi everyone,

I am new to Retool and I need help with getting the scanner working on my mobile app. I have a list of QR codes from 1 through 100 for example that correlates to the id of each item stored in my one of my databases. At the moment, I have a temporary variable storing the value when you click the collectionview so I know so far that it is storing a value properly. Unfortunately, when I try to scan the QR code into the same temporary variable it stores it as null. Does anyone know how to make it store the actual value of the QR code? So far, I have tried setting the temporary variable to {{scanner1.value}} and {{self.value}} when a QR is captured but neither have worked.


Hello @taphlo - Welcome! Assuming you have a single QR code scanned, can you try {{[0] }}?

1 Like

Thanks a lot I was stuck on this for a bit. What does the .data[0] do exactly compared to .value? I just want to learn the difference.

For the Scanner, .data is where the scanned items are stored. So, .data[0] references the first item scanned (if you allow multiple items to be scanned, you can reference them by .data[1], .data[2], etc...). The Scanner doesn't have a .value option, which you can see from looking at the State list:

On the scanner item, hit the three dots and select View State

The State list will open, and you can see what's available for that component:

I'm guessing you've used text inputs and/or text areas, which use .value. It can be confusing, but if you get used to checking the State list, you can quickly see what's available.

Hope that helps!