cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

PowerApps attachment control how to check if any attachments have been made

I am in the process of building a PowerApp that stores its data on a SharePoint OnLine list.

One of the fields is meant to be an Attachments Control that may carry one or more files. The record is validated by checking for data in relevant fields; I need to check whether or not the Attachments Control has any items attached to it.

I was unable to find out how to see if the Attachments Control has some property that would at least tell me if there are attachments associated with the control. The Microsoft documentation doesn't seem to describe any such feature, is there something I missed?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Advocate II
Advocate II

Re: PowerApps attachment control how to check if any attachments have been made

I like this idea of counting the attachments

but my goal is to prevent requests from being sent, not having at least 1 attachment

 

I have it with this variable

 

OnAddFile

Set(IsAttached, true)

 

OnRemoveFile

Set(IsAttached, false)

 

and with a condition 

View solution in original post

6 REPLIES 6
Highlighted
Helper I
Helper I

Re: PowerApps attachment control how to check if any attachments have been made

you can check the number of attachments using countrows:

CountRows(ThisItem.Attachments)

 

Highlighted
Community Support
Community Support

Re: PowerApps attachment control how to check if any attachments have been made

Hi @javierz ,

Could you please share a bit more about your scenario?

Do you want to check if there are some files attached to the Attachment control in your Edit form?

If you want to check if there are some files attached to the Attachment control in your Edit form, I agree with @bboardman thought almost.

Currently, within PowerApps, there is no direct property supported in Attachments control to tell us that if there are attachments associated with it. As an alternative solution, you could consider take a try to count the amount of the files attached within the Attachments control.

On your side, please take a try with the following formula:7.JPG

Set the Text proeprty of the Label control to following:

"Attachments Amount: " & CountRows(DataCardValue13.Attachments) /* <-- DataCardValue13 represents the Attachments control in my Edit form */

On your side, you should take a try with the following formula:

CountRows(YourAttachmentsControl.Attachments)

if the result above formula returns is more than 0, it means that there are attachments attached within the Attachments control in your Edit form.

 

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.
Highlighted
Advocate II
Advocate II

Re: PowerApps attachment control how to check if any attachments have been made

I like this idea of counting the attachments

but my goal is to prevent requests from being sent, not having at least 1 attachment

 

I have it with this variable

 

OnAddFile

Set(IsAttached, true)

 

OnRemoveFile

Set(IsAttached, false)

 

and with a condition 

View solution in original post

Highlighted
Helper III
Helper III

Re: PowerApps attachment control how to check if any attachments have been made

I wanted to disable Submit button if no attachment is attached. used the below on DisplayMode of the button. AttachmentsNF is my attachment card. 

If( 
CountRows(AttachmentsNF.Attachments)>0 ,
    DisplayMode.Edit, DisplayMode.Disabled
    )

Highlighted
Advocate II
Advocate II

Re: PowerApps attachment control how to check if any attachments have been made

Now, this option is readily available by setting Data Required properties to false.
Located under Advanced properties.  

Highlighted
Advocate I
Advocate I

Re: PowerApps attachment control how to check if any attachments have been made

Under Action and Advanced -- using the OnAddFile and OnRemoveFile fields is the way to go here.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,733)