Adding Attachments from Manage Database to Reports
We received a report request from a client that does a lot of government business and needs to send receipts documenting every expense entered into ConnectWise. Employees attach their receipts to the expense record in ConnectWise Manage. Rather than manually gathering all the receipts, they wanted to automate the process. After a lot of trial and error, I figured out a way that to get Report Writer to let us do this. The end result was an updated invoice template, showing all the applicable receipts on the last page.
This guide is specifically for image files attached to expenses but the same basic steps should apply to any type of attachment in CWM. This process works for both self-hosted and cloud partners.
Basic Setup to Attach Images from ConnectWise to Reports
To start, you’ll need a report that includes the “v_rpt_Document” data source. Add a new field to the report (I chose Filename) and set the Description to IMG.
Click the Advanced Field Options button (gear icon) and copy/paste this text (including quotes), replacing the beginning part of the URL to match your URL if needed:
‘<img src=”https://na.myconnectwise.net/v4_6_release/services/system_io/FileManagement/FileDownload.aspx?RecordId=’+CONVERT(varchar(10),[DM_Document_RecID])+’&pathToFile=’+[Filename]+'”altt=””>’
Now, go to Design Form and click the HTML button. Enter the following custom HTML and save.
<!–[repeater]–>
[IMG]
<!–[/repeater]–>
Testing
Before testing this, you’ll probably want to limit the results to 100 or less so you don’t bog down CW. You’ll also want to set up filters to just go after the image type(s) you want and perhaps filter by Last_Update Or, if you have a particular record to test against like a ticket number, filter for that.
Image Formatting
An additional consideration in the expense receipt attachment example is that the source images may come through in several different sizes. You may want to add something like style=”max-width:200px” before the closing > in your IMG tag. This will preserve the width/height ratio but not allow images to be over 200 pixels wide.
Example Run
Here’s how the example looks in our test database when showing last 100 results and filtering by JPG (with images capped at 250px wide).
Adding Images to Your Existing Report
The exact process will vary depending on where your source documents are in CWM. In this example, you could create a modified expense subreport for your custom invoice and join in the v_rpt_Documents table on the EX_Detail_RecID field. If you need help creating a custom report using the image functionality, feel free to reach out to us or point your friendly ConnectWise consultant to this blog post.
Additional Resources
ConnectWise documentation doesn’t mention this capability and there’s always the possibility a future update could require changes to the URL. For a list of officially supported ways to link reports to CWM, see this knowledgebase article.
Want to do more?
Now you know how to attach images from ConnectWise to reports. Do you want to do more of your own ConnectWise reporting in Report Writer, Power BI, or another reporting tool? Contact usfor one-on-one help or connect with us on the ConnectWise subreddit or the ConnectWise University Forums.