cancel
Showing results for 
Search instead for 
Did you mean: 

Build a proposal document dynamically using SharePoint and Flow

This guide details how to build a Microsoft Flow solution which dynamically creates a Microsoft Word document based user-selected options entered within a SharePoint list and is based on this simple scenario:

A SharePoint list is used to capture product proposal requests, and upon posting a request a proposal document should be automatically created containing product information related to the products selected within the request.

Configure SharePoint

This solution uses four separate SharePoint lists details below:

  • SharePoint Library: Products - Word Documents
  • SharePoint List: Proposals
  • SharePoint List: Products
  • SharePoint Library: <Selected Destination Library>

SharePoint Library: Products - Word Documents

This SharePoint library is used to store a document for each specific product, no additional metadata has been added to the library.

1.png

SharePoint List: Products

The products list contains a list of all the products. Each product should have a corresponding entry within the 'Products - Word Documents' library and named exactly the same excluding the file extension, for example:

  • Products - Word Documents Entry: 'Flow Connector.docx'
  • Products Entry: 'Flow Connector'

NOTE: As you build this flow you might think you don't need the 'Products' list and that the 'Products - Word Documents' library could be used in isolation... you'd be correct! However, the degree of separation will make it a lot easier to scale and add additional capability in future so we recommend separating.

2.png

SharePoint List: Proposals

This SharePoint list is used to capture the proposal requests and is configured as follows:

3.png

A single Lookup column named 'Products' associated with the 'Products' list has been added with the following configuration:

4.png

Upon data entry it should look as follows:

5.png

Building the Flow

1. Create a new Flow using the 'Automated -- from blank' option

6.png

2. Enter a name for the Flow, select the 'When an item is created' SharePoint trigger action, click 'Create'

7.png

3. Configure the 'When an item is created' SharePoint trigger action

3.a. Site Address: Enter the location of the SharePoint site where the configured lists are held.

3.b. List Name: Select the 'Proposals' list

8.png

4. Add a 'Initialize variable' action

4.a. (Optional): Rename the action to 'Word Documents for Merging'

9.png

4.b. Name: Set to 'ProposalDocuments'

4.c. Type: Set to 'Array'

10.png

5. Add an 'Apply to each' control action

5.a. Select an output from previous steps: Select the 'Products' property from the 'When an item is created' SharePoint trigger action.

11.png

5. Inside the 'Apply to each' action; Add a 'Get file content using path' SharePoint action

5.a. Site Address: Enter the location of the SharePoint site where the configured lists are held.

5.b. File Path: Manually select any file from the 'Products - Word Documents' library

12.png

5.c. File Path: Select the filename omitting the extension and then select the 'Products Value' property from the 'When an item is created' SharePoint trigger action

14.png

5.d. File Path: The final configured value should appear as follows

15.png

6. Add an 'Append to array variable' action

6.a. Name: Select the previously created 'ProposalDocuments' variable

16.png

6.c. Value: Copy and paste the following value into the 'Value' field

{
"fileName": "@{items('Apply_to_each')?['Value']}.docx",
"fileContent": "@{body('Get_file_content_using_path')?['$content']}"
}

17.png

NOTE: If you have renamed either the trigger action or the 'Apply to each' action you will need to modify the copied value to reference the updated action names

7. Underneath the 'Apply to each' action; Add a 'Merge Word Documents' Encodian action

7.a. Filename: Set the name the proposal document which will be created. For this example, we have used the 'Title' property from the 'When an item is created' SharePoint trigger action concatenated with '.docx'.

18.png

7.b. Click the 'Switch to input entire array icon'

19.png

7.c. Remove any existing text within the 'Documents' field

20.png

7.d. Documents: Select the 'ProposalDocuments' variable

21.png

8. Add a 'Create file' SharePoint action

8.a. Site Address: Set to the value of the SharePoint site which contains the target document library

8.b. Folder Path: Set to the value of the target SharePoint folder

22.png

8.c. File Name: Select the 'Filename' property from the 'Merge Word Documents' Encodian action

23.png

8.d. File Content: Select the 'File Content' property from the 'Merge Word Documents' Encodian action

24.png

9. The completed flow should follow this construct:

25.png

10. Now lets test the flow!

26.png

11. Select 'I'll perform the trigger action', click 'Save & Test'

27.png

12. Go to SharePoint and add a new entry into the 'Proposals' list

28.png

13. Verify the Flow has executed successfully

29.png

14. ... the merged document containing the correct documents has been created.

30.png

31.png

Finally...

This post should provide you with a good base solution which you can build upon to create further complex solutions which dynamically generate documents based on user defined input.

Thanks for reading!

Meet Our Blog Authors
  • Working daily with Microsoft Cloud to deliver the needs of my company, my customers and various Microsoft communities and forums. | Office 365 | Flow | PowerShell | PowerApps | SharePoint |
  • Co-founder of https://plumsail.com, Office 365 and SharePoint expert. Passionate about design and development of easy to use, convenient and flexible products.
  • Microsoft Business Apps MVP. Owner of ThriveFast, an Office 365 consulting company.
  • 7x Microsoft Business Solutions MVP (CRM)
  • I'm keen in MS technologies, SharePoint, Office 365 and development for them
  • Daniel is a Business Productivity Consultant & Microsoft Business Solutions MVP who is very enthusiastic about all things Office 365, Microsoft Flow, PowerApps, Azure & SharePoint (Online). Since the preview, Daniel has been working with Microsoft Flow and later on with Microsoft PowerApps. That led to him being awarded an MVP Award for Business Solutions. He loves to blog, present and evangelize about improving productivity in the modern workspace with these amazing tools!
  • Michelle is an Office 365 solution architect in Twin Cities, MN. She has been delivering business collaboration solutions for years with her focus on SharePoint and Office 365. Michelle is a recent board member of the Minnesota Office 365 User Group and has been a member of the SharePoint community since 2009. She is a frequent speaker at MNSPUG and SharePoint Saturday and co-chaired the Legal SharePoint User Group for 4 years. Her most frequent projects have involved rolling out a large deployment of Office 365, SharePoint Online intranet, build of a "CHAMPS" Office 365 user adoption program and most recently, SharePoint On-Premise to Online Migration. Michelle is very excited about cloud technology as it is shifting her IT Pro focus to collaboration strategy and technical adoption.
  • I'm a Microsoft Office Servers and Services MVP with a special interest in SharePoint, Office 365, Microsoft Flow, Microsoft Teams and PowerApps. I work at Triad Group Plc ( https://triad.co.uk)
  • Passionate #Programmer #SharePoint #SPFx #Office365 #MSFlow | C-sharpCorner MVP | SharePoint StackOverflow, Github, PnP contributor