By Khurram Jawaid

Effortless Data and File
Handling with SharePoint
and Microsoft Word

As a CRM consultant, one of the common challenges we often encounter is meeting our clients’ demand for a more efficient and streamlined way to save Word files on SharePoint. Many business organizations understand the importance of SharePoint as a collaborative platform, but manually saving files can be a tedious and time-consuming task. This is where the concept of dynamic saving comes into play, revolutionizing the way we handle document management.

In the dynamic world of business, where speed and efficiency are paramount, it’s crucial to have a system that not only facilitates easy file storage but also promotes real-time collaboration. With Power Automate Flow we’re able to address this need effectively.

Add a Trigger Point

As we know every power automate needs a trigger to kickstart the process. Here I’m using the Dataverse connector you can use any trigger based on your business requirement.

Send an HTTP Request to SharePoint

This action allows you to communicate with your SharePoint environment, sending HTTP requests to perform various operations like retrieving data, updating lists. This action allows you to use custom HTTP requests to SharePoint, specifying the method (GET, POST, PUT, DELETE) and the URL to target specific SharePoint resources.

Site Address

Here by default your organization site options will be given but in our scenario we select “Enter custom value” and select environment variable for SharePoint site using dynamic content.

Method

We select “GET” method as we need to fetch folders from SharePoint drive.

Uri

SharePoint’s default document drive, often referred to as the “Documents” folder, is a cornerstone of document management in SharePoint sites. To access this drive programmatically, we utilize a specific API endpoint. By sending a request to “_api/v2.1/drives?$select=id, name” and then applying a filter to identify the drive with the name “Documents”. This method is especially valuable for automation and integration tasks, allowing us to streamline operations and enhance document management within SharePoint sites. Whether you’re working on custom solutions or automating routine tasks, understanding how to access and utilize this default document drive is a valuable skill for maximizing the potential of SharePoint.

Headers

Content-Type: This header specifies the format of the data you are sending in your HTTP request. In this case, we wrote “application/json,” indicating that the data being sent is in JSON format. SharePoint API endpoints often expect data to be sent in JSON format, making this header crucial for correctly formatting your request.

Accept: This header specifies the format you expect the response from the server to be in. In your example, you’ve mentioned “application/json,” indicating that you expect the response data to be in JSON format. This header helps ensure that the response is in a format that your application or workflow can handle.

Add Compose Action

Here we simply use this expression essentially extracting the ‘id’ property from the “Send an HTTP request to SharePoint for documents” action.

Make Word Document Dynamic

Now, before moving to next step, we need to make “word document” dynamic.

Select the word you want it to be dynamic , go to “Developer” tab and click on “Aa” icon known as “Rich

Text Content Control” in my case I have selected “Address” and “Country”.

After that click on “Properties,” give the field a title. This title is important because it will be displayed in Power Automate, helping you easily identify the specific field. In my case, I’ve given the title as “If applicable, Address Line 2”. Once you’ve made your Word document dynamic, add another “Compose” action, and leave it empty for now. In my example, I named it “Template”.

Populate Microsoft Word

Add the action “Populate a Microsoft Word Template” to select your dynamic document saved in your preferred location. In my example, it’s saved in the “Documents” folder.

Choose your saved dynamic word document from SharePoint folder (mine is in “Documents”).

The system will list all the dynamic fields from your Word document. You can add your Dataverse field to this list.

Now click on 3 dots that you see at right upper corner and select peek code from there you will get your fields dynamic file schema as shown below.

Now remember that empty action named as “Template”. We now define “dynamic file schema” in it .

The syntax should be “DYNAMIC FILE SCHEMA CODE” : “field name from Dataverse”.

Before moving forward, we need to update few things in action “Populate a Microsoft Word Template”.

Begin by selecting “Document Library” from the dropdown menu. This step is crucial as it helps us generate a dynamic file schema name. Because, we need to define this schema in the “Template” action. After having “dynamic file schema” values, replace “Document Library” with “Enter custom value.”

Now, we need to connect the dots. For the “Document Library,” select the output of the “Compose” action and the “Template” output will be used

And we will select output of “compose” action from dynamic content. And in dynamicFileSchema we will give the output of “template” in “DynamicFileSchema” as shown below.

Create File in SharePoint

Now the last step is to select action named ”Create file” of SharePoint folder.

Give value in required field like Site Address, Folder Path, File Name and File Content. And that’s it your dynamic word file will be created in your selected SharePoint folder with dynamics values in it.

In conclusion, dynamic document saving with Power Automate Flow is a game-changer for SharePoint document management. It eliminates the manual effort of saving Word files and offers a streamlined, efficient solution that promotes real-time collaboration. This approach empowers businesses to thrive in today’s fast-paced, dynamic environment, making document management in SharePoint a breeze.

Let's Shape the Future Together!

Ready to shape the future of your business? Connect with ITKnocks, your catalyst for innovation. Let’s collaborate and transform possibilities into reality. Contact us, and let the possibilities unfold!