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

Re: Attachments: How to count only saved attachments?

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
Highlighted
Community Champion
Community Champion

Re: Attachments: How to count only saved attachments?

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
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,374)