web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Automatically adding attachments to sharepoint list item from OneDrive

(0) ShareShare
ReportReport
Posted on by 4
Good day,
 
A bit new with Power Automate... I am trying to build a flow that will automatically add attachments to a sharepoint list item.
 
It is a shared business OneDrive. So what we are trying to do :
 
If a file or multiple files in .pdf format is/are added to a specific folder in the shared OneDrive (they also show up in sharepoint document library), attach them to the sharepoint item if the files contain the item title name in the file name.
 
so if files are named 123-asd.pdf and zzz-asd.pdf, then add it to the sharepoint list item that has the title asd
 
Sometimes those are files are modified, so the sharepoint list item must have the latest version of the files.
 
My current flow and I am unable to get it to work :
 
1. When a file is created (properties only)
- I choose the site address
- I select the Documents library containing the file
 
2. Get file content
- Again, selecting the same site address
- File Identifier : Identifier from When a file is created (properties only)
 
3. Condition
endsWith(triggerOutputs()?['body/{FilenameWithExtension}'], '.pdf') is equal to True
True -> Get items
             - From there I selected the site address and the list name
False -> Currently none
 
4. Condition (Under Get items)
contains(triggerOutputs()?['body/{FilenameWithExtension}'], item()?['Title']) is greater than 0
True -> Update item
        - I select the Site address and the list name. For ID I select ID from For each and the title from For each.
        Add attachment
        - I select the correct site address and list name. ID from For each.
        - File name : triggerOutputs()?['body/{FilenameWithExtension}']
        - File Contant : Body from Get file content
 
Obviously, I did not add anything to update the file if it is modified, but the currently flow that I have is not working. In fact, it added the same attachment to all the list items, even if it did not contain the list item in the file name.
 
How can I fix my flow and get it to work correctly?
Thank you!
I have the same question (0)
  • chiaraalina Profile Picture
    1,125 on at
    Automatically adding attachments to sharepoint list item from OneDrive
    Hi
     
    The contains(triggerOutputs()?['body/{FilenameWithExtension}'], item()?['Title']) is greater than 0 expression doesn't make sense because
    contains() returns a boolean, not an index/number and comparing to > 0 can lead to the condition effectively always being true.
     
    You should use something like this:

    contains(
      toLower(triggerOutputs()?['body/{FilenameWithExtension}']),
      toLower(items('Apply_to_each')?['Title'])
    )

    and then compare it (equals to) to true
     
    Can you share more details and maybe screenshot of your Apply to each action.
  • CU07061759-0 Profile Picture
    4 on at
    Automatically adding attachments to sharepoint list item from OneDrive
    I apologize for the late reply, overwhelmed with work this week.
     
    That is all currently. I can't get it to work correctly. However, I also wish to optimize it... I believe I should add a Filter Query to speed things up, because it works fine in my test sharepoint, but we have thousands of files in the real one.
     
    Thank you!
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Coming soon: forum hierarchy changes

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 544 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 482 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 287

Last 30 days Overall leaderboard