Copy link to clipboard
Copied
I've created a service estimate document that contains fields that need to produce the multiplied product of two other. Unfortunately, the field does not display that product. Just still shows as 0.00
Copy link to clipboard
Copied
We need a bit more information: How are you multiplying the two fields? There are at least three different methods to create calculation scripts, how are you doing this? Be as specific as possible? Are you getting an error message on the Javascript console? You can bring up the console via Ctrl-J or Cmd-J. What are the input fields? Are these text fields, or other field types? If they are text fields, what exactly do you enter?
Copy link to clipboard
Copied
Thanks Karl. I did a simple calculation in the properties screen:
All these are text fields and are formatted as Number with 2 decimal points. The inputs would be typically 1-4 or 5 for the qty field and the Text148 would be a dollar amount.
Copy link to clipboard
Copied
Karl, Please forgive my stupidity!!! I just noticed I incorrectly selected the wrong field for calculation. However, on another issue, how can I have a field not display anything if it is zero?
Copy link to clipboard
Copied
To suppress the result if it's zero, you will have to use a custom formatting script:
if (event.value == 0) {
event.value = "";
}
Copy link to clipboard
Copied
So, if you'll indulge me, do I have to custom format the whole script?
Copy link to clipboard
Copied
No, just for the one field that you want to suppress the zero in. Bring up the field properties, then go to the "Format" tab and select "Custom". This will show two different custom scripts: The format script and the keystroke script. You want to use the above script as a custom format script:
Copy link to clipboard
Copied
Karl, that worked perfectly!! Thank you so much for your help! By the way, on the fields with the zero suppression, is there a way to add code that shows 2 decimal points when a number populates?
Copy link to clipboard
Copied
Yes. Use the following instead:
if (event.value == 0) {
event.value = "";
}
else {
event.value = util.printf("%.2f", Number(event.value));
}
Copy link to clipboard
Copied
Perfect! Thanks again. Have a great day!
Sent from my iPhone
Find more inspiration, events, and resources on the new Adobe Community
Explore Now