Published on

Attach Images from Microsoft Forms into a SharePoint List item.

Authors

Introduction

So a friend asked me the other day how she could build a simple contact-form where she could upload image attachment and then save it all to a SharePoint list. So I thought I might as well create a blogpost about it! :)

Lets get started:

  1. First visit forms: https://forms.office.com/Pages/DesignPageV2.aspx?prevsubpage=design

  2. Press new form and create your form:

  3. Add an upload file:

Image
  1. Press Collect Responses and Copy the link
Image
  1. Visit power Automate and choose Automated Cloud flow, we want this because we want to trigger each time a new form is submitted

  2. Choose these:

Image
  1. Now save and do a test run! Submit an response.
    This is because we want get the Json from the compose as well as the path for the file
Image
  1. Now check previous run and copy the JSON from the previous run.
Image
  1. Edit the flow and add Parse Json select Outputs as source and press generate from Sample and paste in the json from previous run that you just copied:
Image
  1. Now go into your onedrive copy the path

Here you need to choose choose the Path for your form, it should be under:

/Documents/Apps/Microsoft%20Forms

  1. Now select SharePoint Connector and choose Send an HTTP Request to SharePoint, select the Sharepoint site:
| Name         | Value                                                              |
| ------------ | ------------------------------------------------------------------ |
| Site Address | https://yourTenant.sharepoint.com/sites/yourSite                   |
| Method       | POST                                                               |
| Uri          | _api/web/lists/getbytitle('My Personal information')/items|
| Headers      | Accept: application/json; odata=nometadata                         |
| Headers      | content-type: application/json; odata=nometadata                   |
| Body         |                                                                    |
{
  "__metadata": {
    "type": "SP.Data.LogoUniverseListItem"
  },
  "Title": "Power Automate",
  "ProfileImage": "{\"type\":\"thumbnail\",\"fileName\":\"@{items('Apply_to_each')['name']}\",\"fieldName\":\"ImageColumnName\",\"serverUrl\":\"https://avarante-my.sharepoint.com\",\"serverRelativeUrl\":\"/personal/admin_avarante_onmicrosoft_com/Documents/Apps/Microsoft%20Forms/Personal%20Information%20Form/Question/@{items('Apply_to_each')['name']}\"}"
}

The flow should look something like this

Image

And that should do it:

Image