I have a dropdown with a collection of hours as its item source.
ClearCollect(dropDownHours, {Title:00,Title:01,Title:02,Title:03,Title:04 etc to 24})
I am using a single item collection to hold form data for calculation before I patch it back to a sharepoint list.
The dropdown has the following parameters
Items: dropDownHours
Default: First(workingItem).'Start Hour'
OnChange: Patch(workingItem,First(workingItem),{'Start Hour':Value(Dropdown1_4.Selected.Value)})
When I select an item in the dropdown the collection 'workingItem' is patched correctly but the dropdown then displays the previously selected option.
If I select the same option twice it shows the correct option.
Is this expected behaviour?
Is there a better way to work with temporary data and have it displayed accuratly when the dropdowns are changed?
Solved! Go to Solution.
Hi,
If you would like the Dropdown to revert back to the Default value, you will need to trigger its Reset property true then back to false. This can be done with a context variable.
Wherever you place your Patch() formula, have it trigger the reset:
Patch(); UpdateContext({resetdrop: true}); UpdateContext({resetdrop: false})
Then set the Reset property of your Dropdown to:
resetdrop
This means, "Patch the records, then update the resetdrop variable true, then false so that the Dropdown menu goes back to its Default value."
I did the same as you with a few modifications, and it works as expected.
No Collection
Items: ["01","02","03", ... ,"24"]
Default: First(WorkingItem).StartHour
Patch(WorkingItem,First(WorkingItem),{StartHour:Value(Dropdown1_4.Selected.Value)})
With a space in the SharePoint list field name
First(WorkingItem).Start_x0020_Hour
Patch(WorkingItem,First(WorkingItem),{Start_x0020_Hour:Value(Dropdown1_4.Selected.Value)})
Hi,
If you would like the Dropdown to revert back to the Default value, you will need to trigger its Reset property true then back to false. This can be done with a context variable.
Wherever you place your Patch() formula, have it trigger the reset:
Patch(); UpdateContext({resetdrop: true}); UpdateContext({resetdrop: false})
Then set the Reset property of your Dropdown to:
resetdrop
This means, "Patch the records, then update the resetdrop variable true, then false so that the Dropdown menu goes back to its Default value."
Thanks mr-dang and johnselnaes both ways solve the problem.
mr-dang's solution marked because it means I can keep my current data structures.
Kudos to johnselnaes, I will probably move to using simpler data structures in future.
Hi @SimonMeadows,
It seems my solution is outdated now. I have a new method that is not too much to learn and has great value as a best practice.
First, you can use the Reset() function to reset a control to its default:
Reset(dropDownHours)
Reset() works well for individual controls if you do not have too many.
This method consists of:
Insert one button, change its OnSelect property to:
Set(resetControls,true)
Insert a toggle, change its OnCheck property to:
Reset(Dropdown2); Reset(ListBox1); Reset(Radio1); ... everything you want to reset... Set(resetControls,false)
The button triggers a variable called 'resetControls' to true. When 'resetControls' is true, the toggle activates (it becomes checked). When the toggle activates, it performs all the reset actions, then it switches itself off by setting the 'resetControls' variable to false again.
In each place where you want to reset the controls, you would simply copy and paste:
Set(resetControls,true)
Benefits
I hope this helps anyone who is coming to this solution 🙂
Mr. Dang
__________________
Check out new user group experience and if you are a leader please create your group
Did you miss the call?? Check out the Power Apps Community Call here!
See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.
User | Count |
---|---|
257 | |
241 | |
83 | |
36 | |
28 |
User | Count |
---|---|
301 | |
268 | |
118 | |
68 | |
46 |