Expand my Community achievements bar.

Hide a object if zero

Avatar

Former Community Member
Hi!



I am making a template for a invoice and I am stuck

at this moment.



I have a object that shows the total cost of a row on the invoice.

So far so good... BUT I want it to be invisible if there is no

part cost set.



Now it looks like this:



ArtID......Description..........Quantity...Cost......Row total

--------------------------------------------------------------

FooBar.....This is just a test.....2......50,00.........100,00

..........................................................0,00

..........................................................0,00

..........................................................0,00

..........................................................0,00

..........................................................0,00

..........................................................0,00

..........................................................0,00

..........................................................0,00

--------------------------------------------------------------

.........................................Cost:..........100,00

.........................................Taxes:....:.....25,00

.........................................Total cost:....125,00



As you can see there are a lot of rows ending with 0,00 in the

object "Row total".



I want these "0,00" to be invisible if there is nothing else on

this row... Maybe you could do something like:



if (Cost = "") then

RowTotal.visibility="hidden"

else

RowTotal.visibility="visible"

endif



I hope you understand what I mean... Cheers!
2 Replies

Avatar

Level 7
This scripts runs in the Calculate event of a numeric field and, if NumericField1s value is greater than zero (0), results in the field becoming visible and its value set to the product of NumericField1s value multiplied by 10. If NumericField1s value is zero (0) or less, its value is set to zero (0) and it becomes invisible. Note the order of the lines which set the fields value and the ones which set its presence: The value is set before the presence is set.



The result of this script is that the presence is affected properly depending on the value of NumericField1 however, since the last-executed line is $.presence = visible (or invisible), the value acutally assigned to the field is visible (or invisible) which evaluates to 0 as a numerical value. Therefore, with this script, the value of the product field would always be zero (0).



If you change the order of the lines which set the fields value and presence as follows:



if (Quantity * Cost > 0) then

Quantity * Cost;

$.presence = "visible";

else

0;

$.presence = "hidden";

endif

Avatar

Former Community Member
Okay...
I couldn't make it work out. It always got invisible by using your code.

I've tried this easy one, but as before, it always gets invisible for
some reason...

CODE:
================================

Fields mentioned in this code:

Cost = The cost of a single product
Quantity = Self-explaining
Discount = Discount in percentage
TotalCost = The total cost by taking Cost * Quantity - discount

















zzzz,zz9.99























zzzz,zz9.99



================================

As you can see, I do this:





That should make "TotalCost[0]" visible just by changing
the value in field Cost. Right? Then why won't it? =(

Thanks!