Upload attachment to SharePoint list item using Microsoft Flow
Microsoft Flow is one of the Microsoft offerings for automation. In this series will see how to upload a file to SharePoint ListItem using MSFlow
Workflow for our scenario
Login to Microsoft Flow site and log in to create a new flow.
Expressions: we can read values from Query String will discuss how to pass them next article.
Flow will look like this after the above steps
Add 'SharePoint' connector then select 'SharePoint-GetAttachments'
Add ListName & ID from the dynamic variables
Now 'Add a condition' action to check the count > 0
perform following
Delete attachment - action
Add attachment - action
With this setup, we are good to upload any file to the dynamically configured list item. in next article will see How to upload file via MS Flow endpoint using Javascript and PowerApps integration to this MS Flow using Swagger a.k.a OpenApi. I recommend reading the PowerApps scratch development series, Azure Function integration with PowerApps and What is Microsoft Flow.
-Ratsub
Workflow for our scenario
Login to Microsoft Flow site and log in to create a new flow.
Add action and Type 'Data Operations' connector.
Then choose 'Data operations - Compose' action
Select 'Expression' tab and enter the following to create 'ListName' variable
Repeat this process for all other variables
- ListName - SharePoint list name.
- ItemID - SPList item ID.
- AttachmentContent - Actual attachment content.
- FileName - Attchment name.
Expressions: we can read values from Query String will discuss how to pass them next article.
ListName:
trigger()['outputs']['queries']['listname']
ItemID:
trigger()['outputs']['queries']['itemid']
Attachment Content:
triggerMultipartBody(0)['$content']
fName: - FileName
replace(split(string(split(string(json(concat(triggerOutputs()['body']['$multipart'][0]['headers'],''))['Content-Disposition']),';')[2]),'=')[1],'"','')
Read more about triggers, expressions and functions.
Flow will look like this after the above steps
Add 'SharePoint' connector then select 'SharePoint-GetAttachments'
Add ListName & ID from the dynamic variables
Now 'Add a condition' action to check the count > 0
length(body('Get_attachments'))
perform following
Delete attachment - action
Add attachment - action
With this setup, we are good to upload any file to the dynamically configured list item. in next article will see How to upload file via MS Flow endpoint using Javascript and PowerApps integration to this MS Flow using Swagger a.k.a OpenApi. I recommend reading the PowerApps scratch development series, Azure Function integration with PowerApps and What is Microsoft Flow.
I have question on this post as When you are doing HTTP post request from Postman, how you are gathering data? HTTP POST request just returns status code. So I am wondering we are doing data operation on which data?
ReplyDelete