Conditional Page Breaks in Report Writer
I was recently asked to build a custom invoice to clearly break out payable and non-payable amounts. For invoices with any billable time, they wanted the ticket notes listed out on the next page. If there was no billable time in the billing period, they did not want an extra blank page on the invoice. To accomplish this, follow our guide to creating conditional page breaks in Report Writer.
Normally a situation like this is handled with separate “without notes” and “with notes” invoice versions. Below is the page break followed by the notes. However, the client did not want to go through each invoice every month to choose the proper template. They needed a way to make the page break conditional on whether there was any billable time in the invoice.
I couldn’t find a way to build the conditional page break into the time subreport without ending up with separate pages for every ticket. I tried building the HTML for the page break into a CASE statement so it would only display when Time_Amount > 0. The CASE statement worked but unfortunately Report Writer only interpreted it as a transparent image instead of actually doing a page break. After a lot of trial and error, here’s what I finally came up with. This guide to conditional page breaks in Report Writer is specific to invoices and page breaks but the concept will work for other reports with a drill-down that won’t always apply.
Create a Page Break Report
The first step to creating your conditional page breaks is to create a report with a dataset to drill into from your main report. In this case, I opened the time notes subreport, which using v_rpt_InvoiceTime. Do a Save As and name it Invoice – Page Break. I then deleted the Form data and added only the page break. Make sure the Misc tab includes your drill-down key.
Add the Page Break Report to Your Invoice
Next, open your main invoice report and create a new Field using Billing_Log_RecID. Name it PageBreak. In that field, go to Advanced Field Properties and select your page break subreport.
Now, in the Design Form view, add in your page break before the ticket notes.
Once you’ve followed the above steps, if there is no billable time to display notes for, the conditional page break subreport won’t return any results thus no page break will happen.
Want to do more?
Congratulations! You’ve mastered conditional page breaks. Do you want to do more of your own ConnectWise reporting in Report Writer, Power BI, or another reporting tool? Contact us for one-on-one help or connect with us on the ConnectWise subreddit or the ConnectWise University Forums.