3 Replies Latest reply: Mar 23, 2011 11:54 AM by alexcosby RSS

    Event.Value population delay

    alexcosby Community Member

      I have some forms that require barcodes for scanning purposes.  In order to generate these barcodes, I create a text field using a 3of9 font, set it as read only, and script the value as:

           event.value="*"+this.getField("FIELDNAME").value+"*";

      This normally goes off without a hitch, but i'm having an issue with passing that value from FIELDNAME when FIELDNAME is a scripted value.  For example, in one situation, FIELDNAME is a locked text field with a scripted value of:

           var A = this.getField("PART1").value;
           var B = this.getField("PART2").value;
           var C = this.getField("PART3").value;

           var strPart1 = String(A);
           var strPart2 = String(B);
           var strPart3 = A<2?"0"+String(C):String(C);
           var fullname =  (strPart1 + strPart2 + strPart3);
           event.value = fullname;

      This is being done because "PART1" is a data-mapped field of 7 digits, "PART2" is a data-mapped field of 2 digits, and "PART3" is a data-mapped field of 2 digits that often starts with a leading 0.  They have to be concatenated for the barcode to be proper, but there is no data map for a fully concatenated value.  The FIELDNAME field populates fine, but the barcode only outputs "**".  As soon as any other field in the form is manually filled, the barcode changes to the appropriate "*FIELDNAME*".

       

      I have no validation triggers set anywhere in the form, but this seems to be an event validation gone awry.

       

      Any ideas?

      Thanks in advance,

      A.

        • 1. Re: Event.Value population delay
          George_Johnson CommunityMVP

          Is this a calculate script, or something else? You should get the field values using the valueAsString field property, as opposed to the value property like you are, so that any leading zeroes are retained and so that you're doing string concatenation and not numeric addition. That other code isn't necessary.

          • 2. Re: Event.Value population delay
            George_Johnson CommunityMVP

            I forgot to add, the problem is likely that the field calculation order is incorrect. To set it, go into forms editing mode and

            then select "Forms > Edit Fields > Set Field Calculation Order".

            • 3. Re: Event.Value population delay
              alexcosby Community Member

              I tried to use the appropriate valueAsString property, but was having problems getting it to work properly.  However, setting that calculation order got it all worked out.  A thousand thanks, sahib.  May your camels always have healthy calves.

              -A.

               

              --Edit, found the problem with the valueAsString property I was having (leftover junk from declaring a var as an int).  You're correct, that's a much more efficient way to handle the same issue.  For any interested parties, here's how it turned out:

                   var A = this.getField("FIELD1").valueAsString
                   var B = this.getField("FIELD2").valueAsString;
                   var C = this.getField("FIELD3").valueAsString;


                   var fieldname =  (A+B+C);
                   event.value = fieldname;