cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
javierz
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

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
bboardman
Advocate I
Advocate I

you can check the number of attachments using countrows:

CountRows(ThisItem.Attachments)

 

v-xida-msft
Community Support
Community Support

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.

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

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
    )

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

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

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (65,930)