- Published on
Attach Images from Microsoft Forms into a SharePoint List item.
- Authors
- Name
- Nicolas Kheirallah
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:
First visit forms: https://forms.office.com/Pages/DesignPageV2.aspx?prevsubpage=design
Press new form and create your form:
Add an upload file:
- Press Collect Responses and Copy the link
Visit power Automate and choose Automated Cloud flow, we want this because we want to trigger each time a new form is submitted
Choose these:
- 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
- Now check previous run and copy the JSON from the previous run.
- 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:
- 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
- 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
And that should do it: