Save Purchase orders to SharePoint in D365FO

This article describes, how you can save your reports, generated in D365FO, to SharePoint. Docentric Free Edition has greatly improved the File print destination, and saving to SharePoint is one of its useful features.

Our scenario will cover saving generated purchase orders to a specific location on SharePoint, selected on the Print destination settings form. The output filename should be dynamic, for example it should contain Purchase order ID. Furthermore, we want to save the generated documents to the SharePoint folder dedicated for the corresponding vendor (e.g. named as Vendor account number) within a parent folder named as the current business year (e.g. 2020). If such folder(s) don’t exist, we want them to be created automatically.

Using placeholders

We will use placeholders to dynamically create names of the target SharePoint folders and output files. Placeholders are special constructs in Docentric framework. They get replaced with the corresponding values fetched from the report data source when the report is generated and distributed to the selected print destination. We can use them in print settings such as output filename, SharePoint folder path, email subject and body, Print archive note, etc.

Getting SharePoint ready

There is not much to be done in SharePoint to cover the requirements of our scenario. We have to decide in which SharePoint site we want to store the reports and set access controls, so that users would be able to save the reports.

In our scenario, we are using SharePoint site called Main, where we have a SharePoint library called OutputReports with a folder named PO (short for Purchase orders), as shown in the image below.

In the PO folder we want to dynamically create subfolders for years, and within each year, subfolders for vendor account numbers, and have purchase orders stored automatically in their respective location within this folder structure. We don’t have to create them manually in SharePoint, this will happen automatically upon printing purchase orders from D365FO using Docentric File print destination.

Setting up Docentric File print destination

On the D365FO side, we will use Print management setup to set up File print destination settings. The easiest way to get to the Print management setup form is from Docentric report setup, as shown in the image below.


The image above shows where to set the Save to SharePoint options. In cases, when a user will run the same purchase order report several times, we want the newer file to overwrite the old one, so we’ve set Overwrite file if exists to Yes. Because we want folders to be created dynamically, we’ve set Create non-existing folders to Yes as well.

The easiest way to set the value of Site URL and Folder path fields is that you click the Edit button (the button with the pencil icon), which opens the Folder selection form, as shown in the image below.

Names of available SharePoint sites are displayed on the left side of the form. After selecting one of the sites, the folder tree opens on the right and we can select the folder path, where we want to save our reports. In our case we have selected OutputReports/PO folder path.

We further want reports to be stored by years and within years also by account numbers. We will achieve this by adding placeholders to existing path in the Folder path field. Two placeholders, @CURRENTYEAR@ and @VendAccount@, will be used for this purpose. Each report run will resolve the values of these placeholders and consequently the target folder path as well. If the folder path will not exist yet, it will be created, because we turned on the Create non-existing folders option.

Next image shows how you can select and copy the names of placeholders.

Now our Folder path field contains the following value:

Testing the results

Our print destination setup is done, so let’s run the Purchase order report and check the result.

We will print the purchase order 000017 from Contoso database. The image below shows, that the report has been saved to SharePoint and we can see that correct folders were created. Our placeholders have been successfully resolved!

Finally, let’s take a look at the SharePoint. The purchase order report has been saved in correct folder path and the last two folders in the path were created dynamically because they didn’t exist previously. This is exactly what we wanted.

As you can see it doesn’t take much effort to set up Docentric File print destination to save generated reports to SharePoint.

Saving reports under different credentials

The SharePoint report user field within the Security tab in Docentric AX parameters contains a setting which defines under which credentials the reports will be saved to SharePoint.

If you leave the SharePoint report user field empty, then the report will be saved using credentials of the current user. You can, however, also select one of the users, available in the drop-down menu, when you want to use specific account for saving reports to SharePoint. Security configuration on SharePoint must of course be done separately, which is out of scope of this article.

Coming soon

For our future releases we are planning two interesting new features:

  1. Saving reports to OneDrive as another option on Docentric File print destination.
    This will bring even more flexibility in how you want to distribute your reports but also you will be able to save a bit on SharePoint licenses 😊.
  2. Support for custom attributes in SharePoint.
    Currently, you can save report output files to SharePoint. In the future however, you will also be able to set up custom attributes to be used when saving reports to SharePoint. Stay tuned!

See also

Connect to SharePoint from Windows Explorer >>

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 >>