Copy link to clipboard
Copied
I’m building an invoice template.
I have an “Hr” column and a “Cost” column.
The actions I want the “Cost” Column to perform are as followed:
(Hr = number of hours work, 18 = Hourly rates)
Current Scripting for Hr1-14:
Calculate>Simplified Filed Notation.
Hr*18
Validate>Run Custom Validation script.
if (event.value<0){event.target.textColor=color.red}
else{event.target.textColor=color.black}
if (event.value ==0) event.value ='';
else event.value = defalt;
(Note: Above Script was found on Adobe Forums)
At the end of the “cost” column, they are added or subtracted to show a “Grant Total.”
Current Scripting for Hr1-14:
Calculate>Value is the>Sum (+).
Cost1, Cost2, Cost3, Cost4, Cost5, Cost6, Cost7, Cost8, Cost9, Cost10, Cost11, Cost12, Cost13, Cost14,
I try to make it as easy as possible to understand what I am working on and what the aim is, however, if this is still unclear I can email you the file as you see what is going on.
Copy link to clipboard
Copied
Have opened the Acrobat JavaScript console to see there are any errors?
I would change:
if (event.value ==0) event.value ='';
else event.value = defalt;
to:
if (event.value ==0) event.value ='';
Copy link to clipboard
Copied
Your new script helped the with the "Grand Total" calculations.
However, only when the "Hr" box is "empty".
With a "0" value or the "Hr" is reduced, the "Gand Total" will be wrong.
To correct the "Grand Total", you must go back and enter a "0" then go back and delete the "0" for the "Hr" box.
Also, the display of negative values is deactivated.
Is a when to say, "if the value is less than "0" show in red with a negative sign?
Or am I asking too much of this grogram?
Copy link to clipboard
Copied
KO! So I kinda gave up on having only one "Cost" column that does everything. So I opted for two. "Cost1" and "cost2" and "Sub1" and "Sub2". This also ended up simplifying the coding too.
Below it a list of the code I used in each section as well as an image to help you understand the flow.
Fields using: Rate, Qty, Hr: , Cost1 , Cost2, Sub Hr, Sub1, Sub2, Grand Total.
Command: If the value is empty / "0", show as empty.
Script used:
( Validations > Custom )
if (event.value ==0)
event.value ='';
Fields using: Hr: , Cost1 , Cost2, Sub Hr, Sub1, Sub2, Grand Total.
Command: If the greater than "0", show as Black. If the less than "0", show as Red "-" .
Script used:
( Validations > Custom )
if (event.value<0)
{event.target.textColor=color.red}
else{event.target.textColor=color.black}
Fields using: Rate.
Command: (Each row is marked as Column and row#) multiply the hourly rate by the number of hours worked = ? in each row.
Script used:
( Calculations > Simplified )
Hr# * Rate
Fields using: Grand Total.
Command: Show the full cost of everything and remove any discounts,
Script used:
( Calculations > Simplified )
Sub1+Sub2
Find more inspiration, events, and resources on the new Adobe Community
Explore Now