Copy link to clipboard
Copied
Good day,
I created an invoice. Actually very simple. Quantity times price gives amount. I have 4 calculation fields. If I only want to use 1 field there will be 0.00 in the not used calculations. I would like those lines to stay empty. Is there a way to do this? the calculation in the amount field is QTY1*PRICE1......up to QTY4*PRICE4. Thank you!
HI,
we can just add an else to your if to set the format, something like:
if ( event.value == 0) {
event.value = "";
}else {
var temp = +event.value; // this line is to make sure the variable is a number.
event.value = temp.toFixed(2);
}
Regards
Malcolm
Copy link to clipboard
Copied
Hi,
I am not sure how you calculation works, but could you not place an if and check if the value is 0, and therefore return "". Just a thought.
If you post you calculation code, it would be easier for us to suggest a solution.
Regards
Malcolm
Copy link to clipboard
Copied
Hi Malcolm, please see screenshot. It is a very easy calculation. If you have an idea, please let me know! thanks
Copy link to clipboard
Copied
Hi,
If you add a custom validation script you can change it - something like
Regards
Malcolm
Copy link to clipboard
Copied
Thank you. I did see that script but didn't know where to put it. The code is working now but the output of the calculated field lost its decimals. The amount of 10.00 comes out of 10
Any solution for that? Thank you very much for your help!
Copy link to clipboard
Copied
That validation script will not affect the output formatting.
So the problem must be with the formatting option. What do you have selected?
Copy link to clipboard
Copied
Hi Thom, I placed the script in format category "custom" but it replaces the original "numbers" category so the output is a figure without decimals. I can't think it should be that difficult. I also found out that it is not possible to divide so I had to figure out a way to calculate VAT. That works well. Now just to remove the 0.00 in not used calculation lines. Thank you!!
Copy link to clipboard
Copied
HI,
we can just add an else to your if to set the format, something like:
if ( event.value == 0) {
event.value = "";
}else {
var temp = +event.value; // this line is to make sure the variable is a number.
event.value = temp.toFixed(2);
}
Regards
Malcolm
Copy link to clipboard
Copied
Hi Malcolm, Thank you!! This works great!! I am sure this can help a lot of people making invoice forms in Adobe. Much appreciated!! Thanks again!! Best regards, Rob
Copy link to clipboard
Copied
Hi Malcolm, just one last thing..... it would be great if the output 1234.55 could be like this: 1,234.55
Thanx! Best regards, Rob
Copy link to clipboard
Copied
Hi,
a little regex can solve that
if ( event.value == 0) {
event.value = "";
}else {
var temp = +event.value;
event.value = temp.toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
Regards
Malcolm
Copy link to clipboard
Copied
Thanks again. It is absolutely perfect now!!
Copy link to clipboard
Copied
How about just using the regular formatted print function?
event.value = util.printf("%,0.2f",event.value);
Copy link to clipboard
Copied
Thank you Thom, your help is much appreciated. It is working perfect now!
Copy link to clipboard
Copied
This worked perfectly. Thank you. What would you change if you still need it to be dollar amount $
Copy link to clipboard
Copied
event.value = util.printf("$%,0.2f",event.value);
Copy link to clipboard
Copied
Perfect. Thank you.
Copy link to clipboard
Copied
I tried this solution as a solution to my PPP appllication post, and it got rid of the 2nd date field, it is now blank, but now the 56th day won't calculate.
Here's what i typed in:
if ( Covered_Period == 0) {
to = "";
}else {
var v = getField("Covered_Period").valueAsString;
// Convert string to date
var d = util.scand("mm/dd/yy", v);
// Add 56 days
d.setDate(d.getDate() + 56);
event.value = util.printd("mm/dd/yyyy", d);
}
Any ideas, thx?
Copy link to clipboard
Copied
Please post to a new thread