cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Unbihexium
Helper III
Helper III

Delete a specific attachment in a sharepoint list

Hello all

I try to delete a specific attachment in a sharepoint list via button.
this attachment (pdf document) was generated and attachet with a MS Flow.
I've tried with the following syntax but without success. I get no error...it's just not working.
Have anybody an idea what I doing wrong?


see screenshot "PowerApp Button onselect"
Remove(ListGallery2.Selected.Anlagen.DisplayName;
Filter(ListGallery2.Selected.Anlagen.DisplayName; DisplayName= 'Auftrag ID' & "_" & Bezeichnung & ".pdf" ))

I've also tried with '{Attachments}'
Remove(ListGallery2.Selected.'{Attachments}'.DisplayName;
Filter(ListGallery2.Selected.'{Attachments}'.DisplayName;DisplayName='Auftrag ID'&"_"&Bezeichnung&".pdf"))

Is there an other solution to delete a specific PDF from a sharepoint list "attachment"???

thanks in advance
regards

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Unbihexium ,

Based on the issue that you mentioned, I think there is something wrong with your flow's configuration.

 

Within the "Delete attachment" action in your flow, type in "Ask in PowerApps" dynamic content within the Id field and File Identifier field separately, rather than select the Deleteattachment_Id dynamic content within the "File Identifier" field.

13.JPG

 

After that, save your flow. Then go to your canvas app, remove the flow connection you created before, then re-add a new flow connection into your canvas app, then try your 'FlowName'.Run(...) formula again, check if the issue is solved.

Note: You need to pass two parameter values from your canvas app to your flow rather than one, so you must define the parameter within your flow using "Ask in PowerApps" dynamic content twice. The Id field and File Identifier field of the "Delete attachment" action should be set to "Ask in PowerApps" dynamic content separately.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
PytByt
Post Prodigy
Post Prodigy

Hi @Unbihexium 

I'm not an expert here, but i want to try to help.
Have you tried using Remove formula with LookUp function like this example:

Remove(DataSource, LookUp(DataSource, SpecificID = Gallery1.Selected.SpecificID)));

Regards,
pytbyt 

v-xida-msft
Community Support
Community Support

Hi @Unbihexium ,

Do you want to remove a specific attachment from a List Item in your SP List?

 

If you want to achieve your needs in PowerApps app, I afraid that there is no way to achieve your needs in PowerApps currently.

 

As an alternative solution, you could consider achieve your needs using PowerApps together with Power Automate flow. I have made a test on my side, please consider take a try with the following workaround:

Flow's configuration:

6.JPG

App's configuration:

Within your canvas app, add above flow connection as data source. Remove the Remove formula from the OnSelect property of the "Submit verification" button, instead, add the following formula:

'Flow Name'.Run(
                ListGallery2.Selected.ID,
                LookUp(
                       ListGallery2.Selected.Attachments,
                       DisplayName =  'Auftrag ID'&"_"&Bezeichnung&".pdf"
                ).Id
)

When click the "Submit verification" button, the above flow would be fired, then delete the corresponding attachment based on the passed List Item ID value and File Identifier value from your canvas app.

 

More details about firing a flow from an app, please check the following video:

https://www.youtube.com/watch?v=1wl9AtxWdkg

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi pytbyt 

Thank you for your reply and your hint. I've tried with your suggestion, unfortunately I had no luck with it.

Best regards

Hi Kris

Thanks a lot for your reply. 
"Do you want to remove a specific attachment from a List Item in your SP List?"
Yes exactly what I try to achiev.

I've tried as you said, now I got the following syntax error:  "Invalid number of arguments. receive 2:  expected 1"
Not sure if I did something wrong? 

Best regards

Hi @Unbihexium ,

Based on the issue that you mentioned, I think there is something wrong with your flow's configuration.

 

Within the "Delete attachment" action in your flow, type in "Ask in PowerApps" dynamic content within the Id field and File Identifier field separately, rather than select the Deleteattachment_Id dynamic content within the "File Identifier" field.

13.JPG

 

After that, save your flow. Then go to your canvas app, remove the flow connection you created before, then re-add a new flow connection into your canvas app, then try your 'FlowName'.Run(...) formula again, check if the issue is solved.

Note: You need to pass two parameter values from your canvas app to your flow rather than one, so you must define the parameter within your flow using "Ask in PowerApps" dynamic content twice. The Id field and File Identifier field of the "Delete attachment" action should be set to "Ask in PowerApps" dynamic content separately.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Kris

It works! Thank you so much!! 

Great support from this community!

Best regards and happy weekend

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.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (4,887)