Pull a file and write for example a Yes or No to status. Then work your code to verify if status is No, show scan barcode otherwise display error message and proceed to next question.
Here is how we used this feature.
1. File containing details of beneficiaries was uploaded to xlsform
2. The field officer search for beneficiary using their beneficiary code
3. Field officer complete a questionnaire and scan code on beneficiary card
4. If a constraint field already has a Yes, a warning message is displayed to the user and survey ends otherwise a Yes is written to a column and user continue.
Hope this is helpful. You may also share your code so we can update and send back to you.