Errors on invoice created

We are new to Docentric so have a lot of questions as we try to create documents. I have created a sales invoice that seems to work ok when it is for a product sale generated by a sales order but a service item sold on a free text invoice is causing errors.

See the screenshots in the attachment.
Error on invoice.docx (200.0 KB)

Just wondering how I can correct the formula so it shows as blank, as well in the quantity column to show blank if the quantity is 0. The formula I am referring to is the line amount divided by the quantity in order to get the cost price per unit.

Hi Rudi,

Welcome to the Docentric community!

The issue you are encountering likely comes from division by zero, which is why you are receiving errors or unwanted results.

To tackle this, you have a two options for handling the zero quantity value:

  1. Conditional wrapping: Envelop the @Qty field within an If tagging element, where the expression should be @Qty != 0. This will ensure that the field is only displayed when the @Qty is not equal to 0.
  2. IIF function: Consider utilizing the iif function within the expression of the field tagging element that displays @Qty. This might resemble something like: iif(@Qty != 0, @Qty, ''). In this scenario, if @Qty is not 0, the value of @Qty will be shown; otherwise, an empty value ('') will be displayed.

Let us know if this helped!

That’s great, thank you for the quick reply. This helps so much!

Two other questions:

  • If the qty column is empty, is there a way to hide the label called qty?
  • I am calculating the individual cost of an item by the following formula: @LineAmount div @Qty but when the qty column 0, it returns ∞ or NaN. In this instance, I would like it to return the amount in the SalesPrice column

If you can help with this, we will be well on our way to using our new invoice form.

Much appreciated!

Sure thing Rudi, I recommend referring to the Visual Format Override - specifically the “Hide an entire table column” section for detailed instructions.

You can use the iif function inside the Field tagging element to achieve this in a simple way, and following the same logic as in the post above.

You could use this expression where each time the @Qty equals to 0, the SalesPrice amount is displayed: iif(@Qty=0, @LineAmount, @LineAmount div @Qty)

Wow, all I can say is how helpful this is. Thank you so much, Blaz!

This is perfect. Just made the changes and works amazing with the links you sent.
Thank you again! Much appreciated