Adding multiple constraints to barcode scan (Use the camera to scan the barcode)

Hi All,

I am new to form building and have a form to which i want to add multiple constraints:

if a certain “district” (/suburb) is selected then only barcodes corresponding to that district will not prompt an issue.

basically can i create a contraint using “if”, ie if District_002 = capricon, then the form will only successfully save if barcodes 0-4 are scanned (as per pilot site attached excel)? i get errors after experimenting with contraints:

Attached is the base form and also attached is the list of districts and corresponding barcodes.

Pilot Study participants (Tracking system) Final V2.xlsx (11.9 KB) at9oYCsfs98P4ksjKyMyLMv1.xls (30.5 KB)

Hi @MaxH,

Welcome to the community! Could you kindly please explain your issue so that we understand your issue clearly and see if it’s possible in KoBoToolbox. At the moment your issue seems to be a bit unclear.

Have a great day!

HI Kal,

Thanks for the welcome and prompt response!

Form is to help track a blood sample from the head office all the way to the facility so that there is an audit trail. Routes are attached (40 blood samples being tracked for the pilot).

The form asks the person at the head office to select the destination (province, district and facility) and scan the 5 barcodes destined for the district office.

So for each scan (scan1-5) i want contraints in place to prompt an error (if barcode outside the selected district domain was scanned). there are 5 barcodes per district and 9 unique districts.

after a district has been fully scanned up, then the user can upload the form which is linked to a website which will reflect the dispatch.

Hope this helps.

Max

Basically im not sure how to build in constraint syntax - but also check if it is possible.

logically i need, if district = capricon then barcodes all bar-codes excluding 0-4 should be a constraint. or if district = Ehlanzeni then all barcodes except 10-14 are constraints. Would i need to enumerate a logical expression for all districts, but firstly is it possible to build in complex constraint logic.

Hi @MaxH,

Why would you wish to try the barcode question type when you have an option to control the flow of variables through the cascading select option that is available?

Would you mind having a look at the cascading select support article Adding Cascading Select Questions that should solve your issue.

Or as an alternate you could use the pulldata function to capture the province, district and facility as outlined in the post discussed previously:

Have a great day!

Hi Kal,

Remember I am tracking these barcodes by scanning them at various points on the journey from head office to final destination. (there are 40 locations).

so when they get scanned by the destination using a different form - i am tracking the date and time of that barcode scan in order for me to reflect this info onto a separate site.

But the issue i am havin on this form is that, once the user selects the district in the drop down (which is using pull data) then any barcode can be scanned as it stands ( i want a constraint in place that only the corresponding barcode that is successfully scanned can be uploaded). not sure how cascading select helps me here, because each barcode scan serves as an audit trail.

Hi @MaxH,

Maybe you could use the following constraint with the barcode question type as shown in the image below:

In the survey tab of your xlsform:

image

Reference xlsform:
Barcode 2020 09 10.xlsx (10.0 KB)

My assumption is that maybe you have a barcode allocated for each location. In this case set the constraint for each of those locations as shown in the image above. So in your case you should have 40 barcode acceptable. If a user tries to enter the wrong barcode the system (KoBoCollect android app) should be able to capture but would not allow to proceed further.

You could have the constraint as follows:

.=9789993310464 or .=9788131724293

… and so on. Hope this helps.

Have a great day!

1 Like