cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EpicTriffid
Resolver I
Resolver I

Collecting Attachments from SP List returning same image

Morning all,

 

FYI: There's some sensitive data in here so sadly no screenshots.

 

So I have a SharePoint List called FAQ Dataset where most items contain an attachment. I bring that entire list in faqCol. In order to reduce outcalls from the app, I bring the attachment into a collection called imageCol and then depending on the item selected, lookup the correct image from imageCol based on the item selected from faqCol. 

 

The problem I'm having seems to be that while it works perfectly when editing the app, as soon as I publish it, it fails. 

 

Basically, my image collection looks like this when I run AppStart in the editor:

 

Image TitleImage ID
EvT1
KPI2
PSQS3
Fac4

 

All good. Works great. now, when I run it once published I get:

 

Image TitleImage ID
EvT1
Fac2
Fac3
Fac4

 

It seems to go through the same number of attachments, but replaces most of them with just one of the attachments. In the list they are all still there and accessible. In the editor mode they are all still there and accessible. But once published and loaded up, most of the attachments in my imageCol suddenly become that "Fac" attachment, but with the correct item ID. Not entirely sure what is going wrong. My code for the imageCol collection is:

 

//Attachments Collection
    ClearCollect(preImageCol, 0);
    ClearCollect(
        imageCol,
        Filter(
            Ungroup(
                ForAll(
                    Sequence(
                        CountRows(faqCol)),
                    Collect(
                        preImageCol,
                        Last(preImageCol).Value+1);
                    {
                        Image:Last(FirstN('FAQ Dataset',Last(preImageCol).Value)).Attachments,
                        ID:Last(FirstN('FAQ Dataset',Value)).ID
                    }),
                "Image"),
            !IsBlank(Id)));

 

Bit stumped. Any help would be appreciated and I can offer any additional info required.

 

To sum up, the published app is not doing what the app is doing in editor mode.

1 ACCEPTED SOLUTION

Accepted Solutions
EpicTriffid
Resolver I
Resolver I

And fixed it. It seems that the problem was on both the AppStart and OnVisible properties running the same code. I commented out the AppStart code, and OnVisible still seems to run, and all the attachments are returned perfectly. I hope this helps someone!

To sum up, don't run the same code on both the AppStart and Home Screen OnVisible properties!

View solution in original post

3 REPLIES 3
EpicTriffid
Resolver I
Resolver I

Interesting development. So, if I delete the Fac (actually called FACSP.PNG) attachment from the SP item, everything works perfectly. All of the images are collected against their proper IDs. As soon as I reattach it, the problem comes back. 

EpicTriffid
Resolver I
Resolver I

Another development. The code listed above is on both the AppStart property and the OnVisible property of my Home Screen. When I go into the app, the above error occurs. If I leave the page and return, triggering the OnVisible property of the Home screen, the exact same code runs again, but this time is returns properly. So I can only assume the AppStart code is faltering halfway through?

EpicTriffid
Resolver I
Resolver I

And fixed it. It seems that the problem was on both the AppStart and OnVisible properties running the same code. I commented out the AppStart code, and OnVisible still seems to run, and all the attachments are returned perfectly. I hope this helps someone!

To sum up, don't run the same code on both the AppStart and Home Screen OnVisible properties!

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,128)