cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
leonel_guzman
New Member

Use file input from "For a Selected Item" to add an attachment to a SharePoint list

Hello

I got a SharePoint list (List A) where I run a "For a selected Item" event that collects text and a file (attachment) that I want to use to populate a different list (List B).

 

I can use the text to populate List B through "Create Item", but I haven't been able to use "Add attachment". I've looked for the answer, but I haven't understood how to reference the file content and the file name from "For a Selected Item" to use the information in "Add attachment". 

 

The "For a selected Item" gives the outputs as shown below: text: "Testing flow", and file: ContentBytes and Name for the file, but I can't use them to "Add attachment". I will very much appreciate your help.

 

Output.png

 

Thank you

Leo

7 REPLIES 7
sudharsan1985
Solution Sage
Solution Sage

Hi @leonel_guzman  please refer the image and the steps below

sudharsan1985_1-1643595464702.png

  1. For a selected item you will be able to receive only few information, so you have to use some additional action to retrieve the attachment and then to save it to the new list.
  2. Get attachments action with the ID from the trigger action will get all the attachments of the selected list item
  3. The third action is to create a new item in the list b with the details you have, if you need additional list item metadata, you have to use Get Item with the ID from the trigger action.
  4. You have to loop through the attachments and inside the loop you have to use
    1. Get attachment content by passing the ID and File Identifier from the loop item
    2. Add Attachment by passing the Create Item action ID of the new item and then the content from the above action.

Please try it out and let me know if you have any clarifications.

Hope it helps, please like it or mark it as a solution if it resolves your clarification or issue
-Sudharsan K...

@sudharsan1985 I'm pretty sure that @leonel_guzman means the Attachment that you can attach to the trigger, not the one attached to the item in the SharePoint list. 

 

I'm also looking for a solution for this.

KvB1
Solution Sage
Solution Sage

I'm a bit confused, the contentbytes from the trigger are the ones you want to create the attachment, correct?

 

Why can't you use them?

FlorianSams
Frequent Visitor

Contentbytes is not the issue, the Filename is.

I have played arround a bit and it seems you have to add your own filename object:

 

so just use 

@triggerBody()['file']['name'] 
@triggerBody()['file']['contentBytes']
 
for the name and Content
FlorianSams_0-1647944609654.png

 

 

Thank you.

I'll try

bosco93
New Member

Hi, 

have you been able to manage the content of the file attached to the flow run?

I've been able to extract the name of it using a parse JSON action, but no matter which dynamic content I put in the Content in the create file action, I cannot get a meaningful file. And I'm working with a simple txt file.

Hi bosco93,

 

Nope, I haven't been able to. At some point the requirements changed, and I didn't need it anymore, so I didn't follow up.

 

Good luck!

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,029)