Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!

barcodes based on user-entered text fields

Avatar

Former Community Member
Designer is a great tool for creating barcodes, but I'd like to design a form that will automatically generate a barcode based on a user entered number. The exact layout would be, per line:



User-entered 4 digit number. User-entered text field. Barcode that is based on a pre-set 5 digit string followed by the user-entered 4 digit number.



I can do all this within designer, manually entering in the entire 9 digit string on each barcode, but if I could set it to automatically generate the barcode for each 4 digit entry that would save a ton of time.



I assume there would be a way to script that, but I have no idea where to start. I can do simple calculation of number fields in a total field, that sort of thing, but beyond that I know next to nothing about scripting.



tye
5 Replies

Avatar

Former Community Member
On the calculate event of the barcode you just put (javascript)

if (NumberField.rawValue != null)

{

this.rawValue = "12345" + NumberField.rawValue;

}

Set the default value of the barcode to 123450000



So when you enter the 4 digit number in the NumberField (or whatever you have called it), it should update the Barcode Field automatically.

Avatar

Former Community Member
Thanks for the quick resopnse, but I have a problem with it. As soon as I change the value type on the barcode field from User Entered to Calculated, the barcode disappears and the box has the little plus sign in the bottom right corner as if the barcode is too big to fit in the container. Resizing it doesn't make any difference.



Any idea what I'm doing wrong?



tye

Avatar

Former Community Member
Thomas,



Once you set the value type property for your barcode to be "calculated", the barcode disappearance indicates that it does not know what amount of data that it is expected upon the calculation event takes place. It seems that to undo the change is not possible.



You did not do anything wrong but you need to set the value type for the barcode properly to avoid data overflow.



If you don't want your users to change the barcode, set it to "ready only". Otherwise, set it to "user entered - optional".

Avatar

Former Community Member
Jimmy,



Having the barcode set to read only or user entered takes away the functionality I'm trying to add, that being that the user will enter a 4 digit number in a number field and a barcode will be calculated and generated based on that number plus a pre-determined set of numbers.



Did that make sense?



Oddly enough, I just realized that barcodes have autocalculate built in. If you click on a barcode with the text tool, it brings up the number behind it. Then you can edit it and tab to the next. Another funky thing about it, though, is that it just beeps at me if I try to enter the number that was already next in the string... i.e. a barcode 12345-67890, if I click on it and delete 890 and want to replace it with 881, it will just beep at me when I try to type the 8. I can type 1 then back up and put a couple 8s in front of it, but as long as the number I'm entering is already the next number in the barcode, it just beeps. Of course it's easy to get around that by just selecting the first one that will change, but I still found it odd.



tye

Avatar

Former Community Member
Thomas,



Setting the barcode's "value type" property should not prevent you from achieve what you are trying to do (i.e: You should be able to allow your users to add a four-digit-number to an additional numeric field and concat that number to pre-determined numeric string).



Unless you want your users to be able to edit the barcode's value by clicking on the barcode, then certain value type properties are needed to be considered.



An example can be found
here.