• Introducing Dark Mode! Switch by clicking on the lightbulb icon next to Search or by clicking on Default style at the bottom left of the page!

Adding Conditional fields for Total in rtf

BBritain

VIP Member
I have an invoice issue.

I have totals in the bottom right

Subtotal xxxx.xx <?Total_S_line_Extended_Price_v_ID266?>
Misc xxxx.xx <?Total_N_Line_Extended_Price_v_ID264?>
Freight xxxx.xx <?Total_F_Line_Extended_Price_v_ID268?>
Tax-HST xxxx.xx <?HST_Tax_gv_ID19?>
Tax-PST xxxx.xx <?PST_Tax_gv_ID17?>
Tax-GST xxxx.xx <?GST_Tax_Total_gv_ID273?>

Total yyyy.yy <?Total_Order_ID25?>

Unfortunately, the Total_Order_ID25 is not correct for this particular layout and the total needs to be calculated. I want to add the first six lines amount fields for the Total field. I created the Advanced line:

<?Total_S_line_Extended_Price_v_ID266 + Total_N_Line_Extended_Price_v_ID264 + Total_F_Line_Extended_Price_v_ID268 + HST_Tax_gv_ID19 + PST_Tax_gv_ID17 + GST_Tax_Total_gv_ID273?>

When I run a preview the field is blank.

The second through sixth lines are conditional so any of the rows are zero - it is not printed. When I add only the fields that are in the sample XML:

<?Total_S_line_Extended_Price_v_ID266 + PST_Tax_gv_ID17 + GST_Tax_Total_gv_ID273?>

I successfully get a Total. As soon as I add a field that is not in the sample XML (I have never seen Misc, Freight, or HST), the Total field is blank. Any suggestions?

Regards,
Ben
 

Abhishek Chhajer

Well Known Member
Ben,
I will suggest placing an template variable that will accumulate totals for each of the subtotals based on if they are success. Total variable will then be sum of only successful subtotal if conditions.
Let me know if you need help on syntax.
 

BBritain

VIP Member
Yes! that is exactly what I am looking for, and I would need help as I don't know about creating a template variable or anything beyond that. Thank you, thank you, thank you.

Regards,
Ben
 

BBritain

VIP Member
Hi Abhishek,

I found a solution, but would like to compare notes. I am attaching the template, XML and a white paper I wrote up - for my own benefit. Please review and let me know if my approach is sound and if you have any other solutions.

Any reviews are welcome!

Thanks,
Ben again,
 

Attachments

Top