Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Hide Zero Values

Avatar

Former Community Member
In the "Invoice" template that comes with ES the "Amount" fields are blank unless there is a value in "Quantity" or "Unit Price". The only calculation is "Quantity * UnitPrice". How are the zero values hidden? I've looked at every field possible for some kind of hint as to what suppresses the zero values and I cannot find anything. My form that I am working on shows all zeros in the amount column, sure I could use the template but then I wouldn't learn anything.



Thanks in advance
4 Replies

Avatar

Former Community Member
I assume that you are speaking of the Purchase Order sample. The 0 is showing up because you have a calculation on that field.



On the validation pattern (Edit), there is a checkbox that says allow empty. This in turn is firing the calc for the amount field and making it empty as well.

Avatar

Former Community Member
Paul,



Thanks for the quick response, I'm not so sure that we are talking about the same program as I do not have that choice when the field is selected. I am referring to the "Invoice Template" found when setting up a form from the "File" "New". When I select the field my only options under OBJECT are "Field, Value, Binding". Under the "Edit" menu at the top of the screen I do not have a "Validation pattern" This choice is availabe but grayed out on the "Object", "Value" menu due to the field being Calculated Read Only.



Thanks again in advance.

Avatar

Former Community Member
You can get to the validation patterns from the Object/Field palette.

Avatar

Former Community Member
Ermm... may I help?



Do the calculation with Javascript in the amount field:

if (Quantity.rawValue != null && UnitPrice.rawValue != null)

{this.rawValue = Quantity.rawValue * UnitPrice.rawValue}



Hope that helped

Lisa



Edit:

Equivalent for the total Amount:

if (Amount1.rawValue == null && Amount2.rawValue == null ...)

{this.rawValue = null;}

else

{this.rawValue = Amount1.rawValue + Amount2.rawValue ....;}