Solved! Go to Solution.
I have created an idea for the Reset property of galleries. Please add your kudos to it, thanks.
https://powerusers.microsoft.com/t5/PowerApps-Ideas/Add-a-Reset-property-to-galleries/idi-p/18128
I have edited the above post, now the button always resets the selection to the second default record in the Default property If statement. @lifelongjourney does this resolve your need?
LifeLong,
I see what you are trying I think. So the first record with todays date and your ID is what you want default to take you to, yes?
In that case, and this applys anytime a function takes an expression, you should be able to modify it as follows:
LookUp(roster_on_call, Date=Today() && ID=currentUserID)
the && above is a logical(boolean) AND which requires that both expressions result to true. This should take you to that record when you start the application.
Meneghino is right though, once you manually select something, the default no longer works until you update it. Using a button would be a good way to do that, but you can basically use any event driven property of any control to perform it as well.
Hope that works for ya!
@Meneghino and @TschoofBAHthanks for your responses, you've both moved further forward than I can get. @Meneghino, the second item in your "bearing in mind" list was:
2. When the app is started, the gallery will show the Default item and it will be selected
This is currently not happening. This is the most critical for me. if I can have a Today button that resets the gallery back to the default, that'd be great, but this relies on the Default property working in the first place, which it isn't for me (yet!).
Maybe it's because the data source (a SharePoint list) has Lookup columns? This is the spec of the used columns:
DataSource = 'On Call Roster', a SharePoint list
NB: I don't have access to the list settings, so I can't unify the column settings for Begin and End
Gallery control = galRoster
galRoster.Items = 'On Call Roster'
galRoster.Default = First(Filter('On Call Roster', DateDiff(Today(), DateValue(End, "en-US"), Days) > 0))
I also have a textbox control, lblCurrentRosterID, which displays the current ID, just to reassure me that I am getting the correct ID
lblCurrentRosterID = "CurrentRosterID: " & First(Filter('On Call Roster', DateDiff(Today(), DateValue(End; "en-US"), Days) > 0)).ID
If this is another Lookup support issue in PowerApps, will be very frustrated...
Hi @lifelongjourney thanks for being so specific with your questions.
There are a few reasons I can think of why the Default may not be working, so let's try a simple test.
What happens if you simply do this?
galRoster.Default = Last ('On Call Roster')
Does the app open up with the last item showing and selected? (instead of the first one showing and nothing being selected)
Also, just to make double sure all is working, I would have another text box with .Text = galRoster.Selected.ID
This should show blank on app startup if Default is not working as expected, otherwise it should show an ID (in our test the ID of the last item)
PS Also try this
Create a button with .OnSelect = UpdateContext({ResetVar = true}); UpdateContext({ResetVar = false})
Set galRoster.Default = If(ResetVar, First('On Call Roster'), Last('On Call Roster'))
See if the button manages to force selection of the last item. Please let me know.
@Meneghino great suggestion for follow up.
I changed galRoster.Default to Last ('On Call Roster') and setup lblGallerySelectedID.Text = galRoster.Selected.ID as recommended.
The first one shows nothing being selected, and the textbox shows blank on app startup.
I liked your button idea, I had a slightly different take and created two buttons.
ButtonTrue.OnSelect = UpdateContext({ResetVar: true})
ButtonFalse.OnSelect = UpdateContext({ResetVar: false})
Before clicking either button, I would select a different entry, for example 17.
Both ButtonTrue and ButtonFalse behaved in the same way. If a button click changed the ResetVar from its previous value, the lblSelectedRosterID would be blank. I then select entry 17, and clicked the same button again. This of course did not change the ResetVar. lblSelectedRosterID stayed at 17. Same for the third and fourth clicks etc. Then if I click the other button, the loop starts again.
In other words, not even First('On Call Roster') is working, let alone Last(). 😞
What else you got in mind?
OMG this worked! I've refactored my code back to my original functions and it's working! Thankyou @Meneghino!
@lifelongjourney, you are welcome.
Please add you kudos to this idea if you agree...
https://powerusers.microsoft.com/t5/PowerApps-Ideas/Add-a-Reset-property-to-galleries/idi-p/18128
User | Count |
---|---|
158 | |
97 | |
82 | |
75 | |
59 |
User | Count |
---|---|
195 | |
176 | |
103 | |
94 | |
86 |