4 Replies Latest reply: Aug 25, 2010 10:42 AM by George_Johnson RSS

    Custom Dollar Format

    techie33

      I'm trying to create a custom format for currency within a PDF. 

       

      Currently I have a column of currency that looks like this:

       

      $1,234.56

      $123.45

      $1,234.56

      $12.34

      $1,234.56

      and so on.

       

      What I'm trying to accomplish is to right justify the currency column, but have blanks when the currency isn't at its fullest point.

       

      Here is what im looking for:

       

      $1,234.56

      $   123.45

      $1,234.56

      $     12.34

       

      and so on.

       

      Any ideas?

       

      Thanks

        • 1. Re: Custom Dollar Format
          warzenbeisser Community Member

          You'll probably have to code some elaborate logic for the variable space of "unoccupied" figures and commas. Why not position the dollar sign and the amount separately instead of creating a custom format? However, the problem of figuring out the width of the biggest amount before you are able to determine position coordinates remains ...

          • 2. Re: Custom Dollar Format
            GKaiseril ACP/MVPs

            Have you tired setting the alignment of the field data to 'Right'?

             

            Since the numeric field usually does not have a defined length, how will you know how many leading spaces to provide?

            • 3. Re: Custom Dollar Format
              techie33 Community Member

              What about this logic?

               

              Seperate the field into 2 columns, one just for the dollar sign, the other for the dollar amount.

               

              If an amount is input into the dollar amount field, populate the dollar sign field with a dollar sign.

               

              I think this logic would work, but could anyone help me with the code?

               

              Thanks

              • 4. Re: Custom Dollar Format
                George_Johnson ACP/MVPs

                I think that's a good idea. You could then use code like the following as the custom Validate script of the amount fields:

                 

                // Show the corresponding dollar sign if the value is not blank

                getField("dollarsign1").display = event.value ? display.visible : display.hidden;

                 

                -OR-

                 

                // Show the corresponding dollar sign if the value is not zero or blank

                getField("dollarsign1").display = +event.value ? display.visible : display.hidden;

                 

                You should set up the dollar sign fields so they are read-only and the default value is set to "$".

                 

                In the first script, is will display the dollar sign if there is any numeric value in the field, including "0". Only if the field is blank will the dollar sign not show.

                 

                In the second script, the dollar sign will not show if the field is blank or equal to zero.