Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

## Pattern Display Question

Level 3

I'm guessing this has to do with how it is displayed under the patterns.  I'm looking for a way when the user enters for example \$5,000,000.00 it displays the shorthand version of \$5M instead.  Is this possible?? Any help on this is much appreciated. Thanks.

1 Accepted Solution

Level 10

Hi,

I don't think that there is an automatic/easy way to do this. You probably could do it using script in the exit event. It would have to examine the value, convert it to a string and for each group of three "0", assign a letter.

EG if it finds three zeros, strip them out of the string and add a "K". If there are six zeros, strip them out and add an M.

The trouble is you are taking a Number (which you can do further calculations with) and making it a String (which you can't really work with afterwards).

Also I think that the script will be a bit cumbersome, in dealing with all of the possible inputs. For example, \$5,125,030.15.

Niall

4 Replies

Level 6

Level 3

Okay this works but when I input the numbers it just shows up with a M on the end.  For example, I'm typing in \$5,000,000.00 and it shows up at \$5,000,000.00M when I want it to do \$5M.  Is there a script to do this maybe?  I forgot to mention...I guess what I'm really looking for is if someone types in \$5.00 it displays \$5.00 but if someone puts in \$5.500,000.00 is displays \$5.5M and so on and so on with billions also.

Level 10

Hi,

I don't think that there is an automatic/easy way to do this. You probably could do it using script in the exit event. It would have to examine the value, convert it to a string and for each group of three "0", assign a letter.

EG if it finds three zeros, strip them out of the string and add a "K". If there are six zeros, strip them out and add an M.

The trouble is you are taking a Number (which you can do further calculations with) and making it a String (which you can't really work with afterwards).

Also I think that the script will be a bit cumbersome, in dealing with all of the possible inputs. For example, \$5,125,030.15.

Niall

Level 3

Okay thank you...I was just wondering if there is an easy way to do it but this let's me know there is not.  Thank you!