cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

Re: Odd behavior using First & Filter together - getting *second* record not first unless wait l

@PhilD,

 

I have tried some similar stuff on my side and used a different approach and it seemed to work ok.  Basicly, I took a Sharepoint dataset without any Choice, Lookup or Person columns and let Powerapps create the App from the list. It was about 300 or so items. I then made a collection from the list (colsplist,Splist) and used that as the items in the gallery.  I modified the Edit form and View form screens still had the Datasource was the original Splist but I changed the Item property from Gallery1.Selected to Lookup(Splist, ID=Gallery1.Selected.ID); you need to do that because the datasource of the gallery is no longer identical to the datasource in the Edit form.   In the OnSuccess property of the EditForm, I put in ClearCollect(colsplist,Splist).  When I went back to the Gallery screen, the item was correct.  

I'm not saying that this simple solution would work in your case but using collections whereever possible could cut out the latency issue you are having in your app.  You would need to step back and think over whether it is possible to do that. You will always have to write your changes to the underlying Sharepoint list but use ClearCollect to recreate the collection after you have made the change. 

PhilD
Level 8

Re: Odd behavior using First & Filter together - getting *second* record not first unless wait l

My list looks like this with the unrelated columns hidden.

 

I am finding the last event matching both the EventClass and TaskID (both are my columns, not the unique ID of the event). The ID of the event is shown on the far left. 

 

EventsList.PNG

PhilD
Level 8

Re: Odd behavior using First & Filter together - getting *second* record not first unless wait l

I immediately tried collecting Events then filtering and returning the right one. This was the very first thing I tried actually.

 

Keep in mind the issue is not a gallery not refreshing (I don't show these events to anyone anywhere) but rather just being able to accurately assign the correct item to a variable in a block of code so I can write something to the item. Simple concept really (and one done routinely in functional systems)... when an item updates you find the previous one matching the type and class and write how many minutes it has been from then until now. This builds a table of events with each one having the number of minutes in each status. Won't work though when it can't reliably find the correct one.

 

I appreciate your trying to help but I think I must have some kind of a bigger problem which is unfortunate. I'm supposed to be rolling this out and I don't know how I can when something so simple can't work. I have to assume there are other functions not returning the correct values as well.

PhilD
Level 8

Re: Odd behavior using First & Filter together - getting *second* record not first unless wait l

I discovered that if I used the same exact code in another app I have (which has the same datasources) it  works exactly as expected... I don't know what this means. All the advanced settings for the apps are identical. I can't build this app over again (it took me a very long time). Is my app corrupted somehow? I saved the affected app with a new name but it behaved the same way...  I deleted all the datasources and connectors and re-associated them, no luck.

 

Anyone have any ideas how to troubleshoot this?

 

 

 

PhilD
Level 8

Re: Odd behavior using First & Filter together - getting *second* record not first unless wait l

Interestingly, when the sort is reversed, and it is looking for the first qualifying record, it behaves the same way.

 

Using this code I went in to the first record that qualified (ID:464) and made it not qualify. Went back to my app and pressed button and it returned '464'. Pressed it again and it returned the correct value, '465'.

 

    Refresh(Events);
    Set(varNewPreviousEvent,
        LookUp(Sort(Events,ID, Ascending),               
            EventClass = varCurrentEventClass && TaskID = 983
        )
    )

 

Session ID: c0f61316-1795-4ba2-b1d9-7526c819c929
PowerApps 3.18103.23
Super User
Super User

Re: Odd behavior using First & Filter together - getting *second* record not first unless wait l

what happens if you put a ; at the end of your code and repeat the same code again?
Super User
Super User

Re: Odd behavior using First & Filter together - getting *second* record not first unless wait l

another thought, clear the variable by setting it to “” before loading it again.

PhilD
Level 8

Re: Odd behavior using First & Filter together - getting *second* record not first unless wait l

@Drrickryp you and I must think a lot alike, lol. I tried those very things (even though it felt foolish repeating the code over).

 

I really appreciate your helping - it's been a long day and I don't feel very productive today.

 

Here is what I found out... I created a new app from blank and painstakingly copied all the contents from every screen over to the new 'shell' of an app, saved it and guess what, it works fine (at least for now)!

 

Somewhere along the development (which spanned a fairly long time and saw some significant design changes) the app must have become corrupted somehow.

 

In case anyone on staff stumbles by this and is interested in learning why this happened, here are the session IDs:

 

Non-working app

Session ID: c0f61316-1795-4ba2-b1d9-7526c819c929
PowerApps 3.18103.23

New, working app

Session ID: cc951286-f78b-4b5d-ac12-bf7555e3ab5a
PowerApps 3.18103.23

 

Super User
Super User

Re: Odd behavior using First & Filter together - getting *second* record not first unless wait l

Well congrats on solving the problem. Shame we couldn't figure out why.
PhilD
Level 8

Re: Odd behavior using First & Filter together - getting *second* record not first unless wait l

Thanks, I guess I feel less like I solved the problem and more like I just figured out how to make it go away. Hoping that it doesn't come back... In any event I surely appreciated your help 😊

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 233 members 5,067 guests
Please welcome our newest community members: