cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ilias_ben95
Regular Visitor

Add an attachment to a SP list item or replace attachment if file already exists in attachment column

Hi everyone,

 

I just created a flow to create a word doc and convert it to pdf. Now the fact is that I want to add the pdf (created in my flow) in an attachment column from a SP list item. I know I can do this with the (add attachment) functionality in Power Automate, but when there already exists a file with the same name in that column, I get the error that the file with that name already exists in that column (which is logical). 

 

So my question is if there is any way possible to check if a file already exists in a attachment column and if it does, that the old file can be replaced by the new file.

 

Thank you in advance.

 

Kind regards,

Ilias Benabdellah

1 ACCEPTED SOLUTION

Accepted Solutions
v-qiaqi-msft
Community Support
Community Support

Hi @Ilias_ben95,

Do you want to delete the existing file and replace it with the new added one?

Could you please share a bit more about your scenario?

 

Actually, you should check the display name firstly, if yes, delete the previous file and then add the new attachment:

  1. Get attachments from a list item
  2. Apply to each (for each attachment from the get attachments)
  3. Condition to check, if the current item (attachment) name is the same as the document we want to add
    1. If Yes: Delete the existing attachment from the Item
    2. If No: Do nothing
  4. After the apply to each ran through all attachments and compared it with the new document, we want to attach, leave the loop and add the attachment. If there already was an attachment with the same name, it is deleted by the loop, if there was no attachment before, it will just be added.

vqiaqimsft_0-1639982059266.png

 

Best Regards,
Qi

View solution in original post

1 REPLY 1
v-qiaqi-msft
Community Support
Community Support

Hi @Ilias_ben95,

Do you want to delete the existing file and replace it with the new added one?

Could you please share a bit more about your scenario?

 

Actually, you should check the display name firstly, if yes, delete the previous file and then add the new attachment:

  1. Get attachments from a list item
  2. Apply to each (for each attachment from the get attachments)
  3. Condition to check, if the current item (attachment) name is the same as the document we want to add
    1. If Yes: Delete the existing attachment from the Item
    2. If No: Do nothing
  4. After the apply to each ran through all attachments and compared it with the new document, we want to attach, leave the loop and add the attachment. If there already was an attachment with the same name, it is deleted by the loop, if there was no attachment before, it will just be added.

vqiaqimsft_0-1639982059266.png

 

Best Regards,
Qi

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (3,100)