In this article, you will learn how DocumentsCorePack (DCP) can be used to save generated documents to a specified SharePoint URL in PowerAutomate and via classic workflows. More information about how to create a document via those tools can be found here:
PowerAutomate
Within PowerAutomate, create a new flow and select your trigger. Next, add a “Create Document“ action with the DocumentsCorePack connector. For a refresher on the actions of the DocumentsCorePack connector in PowerAutomate, view this article. Once executed, the generated document will be available as an output parameter within your flow.
To save the generated document to a specified SharePoint URL we utilize the native SharePoint connector. To do this, search for the SharePoint connector and select the Create file action. Then configure the following parameters.
❶ Site Address: Select or enter the SharePoint site address that you would like to save the file to.
❷ Folder Path: Select the folder to store the file in. You must start with an existing library, but can add folders as needed.
❸ File Name: Choose to enter data from the previous step. Select body/File name to have the created document name from the previous step match the SharePoint file name.
❹ File Content: Choose to enter data from the previous step. Select body/Document to have the content of the generated document from the previous step match the file content.
Save your flow and then test it to ensure all is working properly. Then continue to use your flow as desired.
![The Save file action of the SharePoint connector is added to the flow in PowerAutomate.](https://cdn.mscrm-addons.com/wp-content/uploads/2024/06/chrome_zMetX3Czjv-300x136.png)
Figure 1: Use the Save file action of the SharePoint connector
Classic Workflows
Within your workflow, create a new MSCRM-ADDONS.com AutoMergeWorkingItem record and open the settings via [Set Properties].
![The Set Properties for creating an AutoMergeWorkingItem.](https://cdn.mscrm-addons.com/wp-content/uploads/2018/07/2022-11-28_10h57_18-300x197.jpg)
Complete the following fields:
❶ Name: Type in the name of your newly created step. In this example we used “Save File to SharePoint.”
❷ AutoMergeAction: Open the drop-down menu and select CreateDocument. Select this option to create a document in any Microsoft Dynamics 365 standard and/or custom entity.
❸ PrimaryRecordUrl: Insert the PrimaryRecordUrl here by using the Form Assistant on the right side (highlighted). A description of how to set a PrimaryRecordUrl field can be found in this blog article.
❹TemplateToExecute: Open the look-up record and select the template which should be executed.
❺ SharePoint URL: Insert your SharePoint URL here, which can be dynamic or static. If you want to specify a folder, the URL has to end with a ‘/’.
- Example: https://xyz.sharepoint.com/sites/dcp/account/
If you want to specify a folder and a file name then you type the full URL with the filename, but without extension into this field.
- Example: https://xyz.sharepoint.com/sites/dcp/account/myfilename
❻ Direction: Select the direction of your SharePoint service here. In this case Entity to SharePoint because we want to save a generated document based on an entity to SharePoint.
After defining the properties, save your newly created process and do not forget to [Activate] it in the command bar.
Have a look at this blog article to learn how to upload a SharePoint document to an email.
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com.