Save Report to Attachments

We can use the Docentric File print destination and the Save to attachments option to save report to Attachments of the underlying entity, which is the report execution context record, i.e. a record of the report menu item.

Let's say that we want to save the Purchase order report to Attachments of the Purchase order confirmations form when the report is executed. We can do that if we use the Print management setup for the Purchase order report. Navigate to Company/Accounts payable/Setup/Forms and open the Form setup menu item. Then select the Purchase order node and select the Docentric File print destination as a target print destination.

We will turn on the Save to attachments option.

Note that we are using placeholders to form the output filename: PO_<OrderAccount>_<PurchId>.pdf.
About using placeholders in print destinations you can read more here >>

Now run Purchase order from the Purchase order confirmations form that can be open from the All purchase orders list page, by clicking the Use print management button:

We are executing the report for the purchase order with PurchId: 000002 and OrderAccount (vendor ID): US-102. The result is:

  • the PO_US-102_000002.pdf file saved to the specified file location
  • the same file is also saved to the Attachments of the Purchase order confirmations form, i.e. to the VendPurchOrderJour table

If we click the Attach button we can see that the report is attached:

On the Document handling form we can click the Open button in order to open the attached report.

 

For attaching Docentric reports the DOCFile document type is used, and the location of files saved within Attachments depends on how we configure this DocuType.

Save report to Attachments of a different table

Let's say that instead of saving report to Attachments of the Purchase order confirmations form, i.e. if the VendPurchOrderJour table, we want to save the report to Attachments of the PurchTable table, which means that this report will be accessible through Attachments on the All purchase orders list page, or the Purchase order form, or on any other form where this table acts as a master form data source.

In order to achieve that, we need to override the overrideReportRunSettings() method of the Docentric DSP (Data Source Provider) class for the Purchase order report and to change the Report Execution Context record from the VendPurchOrderJour table to the related PurchTable record – in our case a record with PurchId = '000002'.

The Report Execution Context record is otherwise automatically set through _args.record() of an SSRS controller instance. If we print report to the File print destination with the Save to attachments option turned on, the report output file will be attached to the Report Execution Context record that is actually the record of the report menu item.

When we run the report again, we will get the following result:

 

 

If we want to append this Purchase order report to the VendTable table record with AccountNum = 'US-102' instead (displayed in Attachments on the Vendors list page or the Vendor form), we will use the following code:

The related purchTable and vendTable records can be selected and stored into global variables in another method of the DSP class:

When we run the report again, we will get the following result this time:

 

Resources

Class_PurchPurchaseOrderDSP_ChangeContextRec.xpo

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Docentric respects your privacy. Learn how your comment data is processed >>

Docentric respects your privacy. Learn how your comment data is processed >>