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 Automate News & Announcements

Power Automate News & Announcements

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

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (2,889)