Validating a substring

Andrew S

New Member
I'm trying to ensure that only codes that start with a particular letter are scanned in. For instance I have an "employee" field that I want to ensure only receives barcodes that start with "E". I know that I can validate for string length and I can validate against a field, but I can't find a way to validate just the first character of the scanned string.

Is this currently possible in TP?
 

Dan Peluso

Member
Staff member
Hi,

There are a couple of options that could help with this but I think the best approach would be to create a new field as a calculated field. This new calculated field would be defined as a string parse using the TP calc function LEFT,1. The source field for this new calc field should be defined as your barcode field. From this calc field, you can do the validation to match "E" and on a failed validation, you can even direct the field to set focus back to your barcode field. Of course, this new calc field does not have to be visible or even part of the form but can still be used to validate as you need.

Another option is worth mentioning just in case you weren't aware of it. This 2nd option involves our Conditional Logic area which can be configured via the Form Designer toolbar (the last button on the right hand side of the toolbar. Conditional logic allows for alot of custom actions to take on definable events along with definable actions to take; like Alert messages, etc.

If nothing else, option 1 is probably your best bet but check out conditional logic as well; there is a lot of power in that area of TracerPlus.

Please note that Conditional logic is available for TP v9 and later.

Thanks.
 

Andrew S

New Member
Thanks Dan. How do I validate against a static string? I can see how to validate against another field but not how to validate against a string. Do I need to create another field, set its default value, and then validate against that?

Thanks for the suggestion about conditional logic. I'd tried that prior to posting here but couldn't find a way to fail the transaction if the conditional logic fails validation. What am I misssing?

Thanks, Andrew.
 

Andrew S

New Member
I've been unable to get the LEFT function to give me any result. I have a calculated field with my Source Field set, type INDEX and an index value of 1 (I've also tried 0 and 2 without success). In all my testing I've never been able to return a result. What am I doing wrong?
 

OliverR

Member
Normally it should work that way. Have you tried checking the 'Trigger field' checkbox and specifying a trigger field? It should work without it checked (it does here, anyway), but you never know that might make a difference. Keep in mind that the trigger field is probably not your sourcefield, in your case. It'll be whichever field the user scans the value in that you want validated.

upload_2015-11-13_8-51-11.png
 
Top