cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Saya
Frequent Visitor

Setting Default property to First(ThisItem.Attachments) on Attachments Datacard Breaks Entire App

Hello, 

 

I just noticed a strange behaviour on my app. I have a requirement of picking only the latest attachment on my sharepoint list item in case an item has multiple attachments. This can only be achieved on powerapps form by changing the Default property of the attachments datacard from ThisItem.Attachments  to First(ThisItem.Attachments). 

Unfortunately every time i do this and save my page, next time i try to access my app, i find it broken. All my screens turn blank  when i try to edit the app as seen on the image below and also the entire app stops running when i publish it. The problem gets fixed when i revert the Default property back to ThisItem.Attachments. 

Has anyone else faced the same issue? Could this be a bug that needs to be fixed? I really need to be able to pick only the first attachment. Kindly help.

 

 

Blank.PNG

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User III
Super User III

Hi @Saya ,

I doubt the designers of this control had this in mind, so it appears that this code does not perform the required function.

You can still use the code First(ThisItem.Attachments) to access the file and as another idea, put a custom card on the form with an image control and a label. The Image control Image is

First(ThisItem.Attachments).Value

and the Label Text

First(ThisItem.Attachments).DisplayName

 

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

5 REPLIES 5
WarrenBelz
Super User III
Super User III

Hi @Saya ,

I doubt the designers of this control had this in mind, so it appears that this code does not perform the required function.

You can still use the code First(ThisItem.Attachments) to access the file and as another idea, put a custom card on the form with an image control and a label. The Image control Image is

First(ThisItem.Attachments).Value

and the Label Text

First(ThisItem.Attachments).DisplayName

 

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

Saya
Frequent Visitor

Hello @WarrenBelz ,

 

Thank you for your response. Unfortunately the Image control doesn't work. I honestly don't understand why the designer couldn't cater for something important like loading only the first or last attachment in the attachment data card section. I am completely stuck.

Hi @Saya ,

Image control needs to be in a custom card (as with the label), not in the attachments card.

 

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.

Saya
Frequent Visitor

Thank you @WarrenBelz  for the custom card idea. The Image solution finally worked. Since i am working with all sorts of attachments including audios and videos, i decided to approach it a little bit different. I used the label Text property for the attachment name First(ThisItem.Attachments).DisplayName and the attachment icon onSelect property for launching the attachment; 

 Launch(First(ThisItem.Attachments).AbsoluteUri)

video.PNG

 

Thanks @Saya ,

I tend to gravitate to the .Value method as this also works on mobile devices (which will not resolve a SharePoint URL in an image control) as my users are mainly mobile. I am glad you have a working solution.

 

Please consider Accept as Solution as this closes the item and also allows others with similar issues to find it more easily.

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

Top Solution Authors
Top Kudoed Authors
Users online (9,435)