cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Alfie_Smith
Helper I
Helper I

Attachments: How to count only saved attachments?

Hi there.

 

Some context. I have an attachments box for users to insert files. I have a 'submit' button next to it. When the attachments box has 3 attachments, the submit button will change its DisplayMode from 'View' to 'Edit', and vice versa. There is also a save button, so they can save before they submit. 

 

Here's the predicament: I use a count to check how many attachments there are, which is fine, however the count doesn't consider whether they're saved or not. This leads to an issue where there can be 3 unsaved attachments, and the submit button change to 'Edit', but in reality if they aren't saved nothing will be submitted. 

 

Is there a way to count only SAVED attachments, to save this from occurring? 

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User III
Super User III

Hi @Alfie_Smith ,

Yes you can get both totals (saved and unsaved) - you just need to reference two different things. For the number in the control use (saved and unsaved)

CountRows(AttachmentControlName.Attachments)

This can be a label anywhere on the form or set into a variable.

For the number saved - a couple of options - put a label in a card somewhere on the relevant form - you can put it in the attachment control and 

CountRows(ThisItem.Attachments)

will get the number currently saved. - you could hide this and set a variable or display it elsewhere referring to it.

If the form is selected from a gallery and the gallery is based directly on the data source (not a collection)

CountRows(GalleryName.Selected.Attachments)

again you could set a variable on this.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

1 REPLY 1
WarrenBelz
Super User III
Super User III

Hi @Alfie_Smith ,

Yes you can get both totals (saved and unsaved) - you just need to reference two different things. For the number in the control use (saved and unsaved)

CountRows(AttachmentControlName.Attachments)

This can be a label anywhere on the form or set into a variable.

For the number saved - a couple of options - put a label in a card somewhere on the relevant form - you can put it in the attachment control and 

CountRows(ThisItem.Attachments)

will get the number currently saved. - you could hide this and set a variable or display it elsewhere referring to it.

If the form is selected from a gallery and the gallery is based directly on the data source (not a collection)

CountRows(GalleryName.Selected.Attachments)

again you could set a variable on this.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

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

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (49,440)