How to get an attachment provided via FORM added to Sharepoint List

%3CLINGO-SUB%20id%3D%22lingo-sub-1559090%22%20slang%3D%22en-US%22%3EHow%20to%20get%20an%20attachment%20provided%20via%20FORM%20added%20to%20Sharepoint%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1559090%22%20slang%3D%22en-US%22%3E%3CP%3EI've%20created%20a%20FORM%20that%20has%20a%20number%20of%20questions%2C%20including%20the%20option%20for%20a%20user%20to%20add%20an%20attachment.%26nbsp%3B%20Then%20via%20FLOW%20all%20answers%20to%20the%20questions%20are%20getting%20added%20to%20a%20Sharepoint%20List.%26nbsp%3B%20Everything%20is%20working%20great%20except%20the%20attachments%20are%20not%20getting%20stored.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1.%20What%20are%20the%20steps%20to%20enable%20the%20attachment%20a%20user%20provides%20in%20the%20FORM%20to%20get%20added%20to%20a%20Sharepoint%20list%20via%20FLOW%3F%3C%2FP%3E%0A%3CP%3E2.%20How%20do%20I%20add%20an%20Attachment%20column%20in%20Sharepoint%20List%20(maybe%20this%20is%20part%20of%20my%20issue)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAny%20other%20thoughts%3F%26nbsp%3B%20Thanks%20for%20the%20help.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1559090%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EForms%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EForms%20Responses%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1561037%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20get%20an%20attachment%20provided%20via%20FORM%20added%20to%20Sharepoint%20List%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1561037%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F746218%22%20target%3D%22_blank%22%3E%40KristaJ%3C%2FA%3E%26nbsp%3B%20to%20answer%20your%20question%202%20first%2C%20you%20need%20to%20edit%20the%20view%20of%20your%20list%20and%20make%20sure%20the%20Attachments%20column%20is%20displayed%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%220-SP-Attachments.png%22%20style%3D%22width%3A%20937px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F209697iA5EA7791CA9A2760%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%220-SP-Attachments.png%22%20alt%3D%220-SP-Attachments.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20actions%20in%20the%20flow%20to%20get%20the%20uploaded%20file%20and%20attach%20it%20to%20the%20list%20item%20are%20a%20bit%20complicated%20but%20it%20works%20very%20well.%20After%20your%20trigger%20and%20the%20Get%20response%20details%20action%20add%20a%20Parse%20JSON.%20In%20the%20Content%20field%20select%20from%20the%20dynamic%20content%20box%20the%20Forms%20question%20that%20had%20the%20file%20upload%20(in%20my%20case%20it%20was%20%22%3CEM%3EIf%20you%20have%20a%20file%20or%20image%20with%20more%20information%20please%20upload%20it%20here%3C%2FEM%3E%22).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%221-trigger-ParseJSON.png%22%20style%3D%22width%3A%20578px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F209698iF8DFAFE5667156F4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%221-trigger-ParseJSON.png%22%20alt%3D%221-trigger-ParseJSON.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThen%20in%20the%20Schema%20field%20paste%20in%20the%20following%20JSON%20code%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%20%20%22type%22%3A%20%22array%22%2C%0A%20%20%20%20%22items%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22type%22%3A%20%22object%22%2C%0A%20%20%20%20%20%20%20%20%22properties%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22link%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22id%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%7B%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22size%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22integer%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22referenceId%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22driveId%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22string%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22status%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22integer%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22uploadSessionUrl%22%3A%20%7B%7D%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%22required%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22link%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22id%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22size%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22referenceId%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22driveId%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22status%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22uploadSessionUrl%22%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3BNext%2C%20because%20Forms%20saves%20the%20uploaded%20file%20to%20the%20OneDrive%20of%20the%20flow's%20creator%20you%20need%20to%20you%20need%20to%20add%20a%20OneDrive%20action%20to%20get%20the%20file%20content.%20You%20select%20the%20path%20up%20to%20and%20including%20a%20file%20that%20has%20been%20uploaded%2C%20but%20in%20the%20file%20path%20field%20delete%20the%20file%20and%20add%20the%20Expression%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSTRONG%3Efirst(body('Parse_JSON'))%3F%5B'name'%5D%3C%2FSTRONG%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%222-getFifleContentOneDrive.png%22%20style%3D%22width%3A%20953px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F209699i6FD86589A76805DE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%222-getFifleContentOneDrive.png%22%20alt%3D%222-getFifleContentOneDrive.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FSTRONG%3E%3CP%3EWhen%20creating%20the%20list%20item%20you%20can't%20add%20the%20attachment%20at%20the%20same%20time.%20I%20always%20introduce%20a%20short%20delay%20-%2010%20seconds%20is%20fine%20-%20so%20that%20the%20create%20item%20action%20has%20time%20to%20complete%20before%20doing%20anything%20else%20on%20the%20list%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%223-createItem.png%22%20style%3D%22width%3A%20566px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F209701i3561B9CA8966F939%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%223-createItem.png%22%20alt%3D%223-createItem.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3ENext%2C%20add%20an%20Apply%20to%20each%20and%20in%20the%20first%20field%20select%26nbsp%3B%3CSPAN%3EBody%3C%2FSPAN%3E%3CSPAN%3Efrom%20the%20Parse%20JSON%20section%20of%20the%20dynamic%20content%20box.%20Then%20add%20a%20SharePoint%20%3CEM%3EAdd%20attachment%3C%2FEM%3E%20action%20and%20select%20the%20site%20and%20list.%20In%20the%20ID%20field%20select%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EID%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Efrom%20the%20Create%20item%20section%20of%20the%20dynamic%20content.%20In%20the%20File%20name%20field%20select%20Name%20from%20the%20Parse%20JSON%20section%20of%20the%20dynamic%20content.%20For%20the%20File%20content%20field%20select%20File%20content%20from%20the%20Get%20file%20content%20using%20path%20section%20of%20the%20dynamic%20content.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSTRONG%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%224-addAttachment.png%22%20style%3D%22width%3A%20591px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F209702iDA3CDDFEAFCF529D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%224-addAttachment.png%22%20alt%3D%224-addAttachment.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FSTRONG%3E%3CP%3E%26nbsp%3B%3C%2FP%3EYou'll%20probably%20have%20other%20actions%20as%20I%20do%2C%20but%20that's%20all%20the%20actions%20you%20need%20to%20add%20the%20file%20uploaded%20from%20the%20form%20into%20the%20SharePoint%20list.%20So%2C%20in%20live%20use%20I%20have%20uploaded%20an%20image%20in%20the%20form%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%225-formsFile.png%22%20style%3D%22width%3A%20540px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F209704i55FC44D0CA00CF52%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%225-formsFile.png%22%20alt%3D%225-formsFile.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3EThe%20flow%20runs%2C%20creates%20the%20item%20in%20the%20SharePoint%20list%20then%20adds%20the%20attachment%20to%20it.%20In%20the%20view%20it%20will%20show%20there%20is%20an%20attachment.%20When%20I%20edit%20the%20form%20(in%20this%20case%20it's%20a%20PowerApps%20customised%20form)%20the%20attachment%20name%20is%20shown%20and%20clicking%20it%20will%20download%20it%20for%20the%20user.%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%226-SP-list-Result.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F209706iD464140663CCF94B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%226-SP-list-Result.png%22%20alt%3D%226-SP-list-Result.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CP%3ERob%3CBR%20%2F%3ELos%20Gallardos%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23006400%22%3EMicrosoft%20Power%20Automate%20Community%20Super%20User.%3CBR%20%2F%3EIf%20I've%20answered%20your%20question%20or%20solved%20your%20problem%2C%20please%20mark%20this%20question%20as%20answered.%20This%20helps%20others%20who%20have%20the%20same%20question%20find%20a%20solution%20quickly%20via%20the%20forum%20search.%20If%20you%20liked%20my%20response%2C%20please%20consider%20giving%20it%20a%20thumbs%20up.%20Thanks.%3C%2FFONT%3E%3C%2FP%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E
Microsoft

I've created a FORM that has a number of questions, including the option for a user to add an attachment.  Then via FLOW all answers to the questions are getting added to a Sharepoint List.  Everything is working great except the attachments are not getting stored.

 

1. What are the steps to enable the attachment a user provides in the FORM to get added to a Sharepoint list via FLOW?

2. How do I add an Attachment column in Sharepoint List (maybe this is part of my issue)

 

Any other thoughts?  Thanks for the help.

9 Replies

@KristaJ  to answer your question 2 first, you need to edit the view of your list and make sure the Attachments column is displayed:

 

0-SP-Attachments.png

 

The actions in the flow to get the uploaded file and attach it to the list item are a bit complicated but it works very well. After your trigger and the Get response details action add a Parse JSON. In the Content field select from the dynamic content box the Forms question that had the file upload (in my case it was "If you have a file or image with more information please upload it here").

 

1-trigger-ParseJSON.png

 

Then in the Schema field paste in the following JSON code:

 

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "name": {
                "type": "string"
            },
            "link": {
                "type": "string"
            },
            "id": {
                "type": "string"
            },
            "type": {},
            "size": {
                "type": "integer"
            },
            "referenceId": {
                "type": "string"
            },
            "driveId": {
                "type": "string"
            },
            "status": {
                "type": "integer"
            },
            "uploadSessionUrl": {}
        },
        "required": [
            "name",
            "link",
            "id",
            "type",
            "size",
            "referenceId",
            "driveId",
            "status",
            "uploadSessionUrl"
        ]
    }
}

 

 

 Next, because Forms saves the uploaded file to the OneDrive of the flow's creator you need to you need to add a OneDrive action to get the file content. You select the path up to and including a file that has been uploaded, but in the file path field delete the file and add the Expression 

first(body('Parse_JSON'))?['name']
 
2-getFifleContentOneDrive.png

When creating the list item you can't add the attachment at the same time. I always introduce a short delay - 10 seconds is fine - so that the create item action has time to complete before doing anything else on the list:

3-createItem.png

 


Next, add an Apply to each and in the first field select Bodyfrom the Parse JSON section of the dynamic content box. Then add a SharePoint Add attachment action and select the site and list. In the ID field select ID from the Create item section of the dynamic content. In the File name field select Name from the Parse JSON section of the dynamic content. For the File content field select File content from the Get file content using path section of the dynamic content. 

 
4-addAttachment.png

 

You'll probably have other actions as I do, but that's all the actions you need to add the file uploaded from the form into the SharePoint list. So, in live use I have uploaded an image in the form:

5-formsFile.png

 

The flow runs, creates the item in the SharePoint list then adds the attachment to it. In the view it will show there is an attachment. When I edit the form (in this case it's a PowerApps customised form) the attachment name is shown and clicking it will download it for the user.
 
6-SP-list-Result.png
 

Rob
Los Gallardos
Microsoft Power Automate Community Super User.
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

 

@RobElliott Thank you for the how-to.  I follow your guide as exactly as I can tell however, I am running into a problem.  When there is no attachment the flow fails.

@jmillar99 are you only getting this error when there is no attachment? If so, try adding condition so if there is no attachment it skips this step. 

 

1. Check for attachment = True

2. If True do this

3. If False do that

 

Perhaps that'll help

Hi. I'm having exactly the same issue. Can somebody offer up a solution that works. Thanks so much

@kitafocus @KristaJ @jmillar99  make sure that in the Get file content using path action that in the settings you have set the Configure run after so that the is successful and has failed checkboxes are checked. And do the same with the action that follows it, in my case it's a Get user profile (V2). The flow will then run successfully even if no document has been uploaded. My apologies, I missed this rather crucial step out of my earlier post.

 

1-RunAfter-Triage.png

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

@RobElliott My flow works correctly but the attachment in the List is decoded incorrectly. When I download it, it can't be opened properly. Not sure what is going on. Any troubleshooting ideas?

@RachelDaines it's because it's not getting the extension. So in the add attachment action, in the file name field try selecting file name with extension from the dynamic content box. Or if they are all going to be the same extension, e.g. docx, then you can type .docx atthe end of the field.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

@RobElliott I'm running into an issue where File Content isn't an option in my Dynamic Content. Any suggestions?  

iamcstevensonts_0-1627583971677.png