Background
I have a list on SharePoint, with two timestamp(date & time) columns, one called StartTime, and the other one EndTime. Now I have some complex validation logic behind these two timestamps (the most obvious one is EndTime>StartTime). And instead of showing the user a generic validation error text, I want to limit the input user can make so that they never end up with a validation error they have no idea about.
Current Situation
I have created a PowerApps form, and changed the items property of the time dropdown to a formula that only returns valid entries, like this (prettified, the actual code is a one-liner):
/**
* HourValue1 is the dropdown controlling the hour part of StartTime
* MinuteValue1 is the dropdown controlling the minute part of StartTime
* HourValue2 is the dropdown controlling the hour part of EndTime
* MinuteValue2 is the dropdown controlling the minute part of EndTime
*/
HourValue2.Items=Switch(HourValue1.Selected.Value,
"08",["08","09","10","11","12"],
"09",["09","10","11","12"],
"10",["10","11","12"],
"11",["11","12"],
"13",["13","14","15","16","17"],
"14",["14","15","16","17"],
"15",["15","16","17"],
"16",["16","17"],
"17",["17"],
"18",["18","19","20"],
"19",["19","20"],
"20",["20"],
[""])
MinuteValue2.Items=Switch(HourValue2.Selected.Value,
"",[""],
"12",["00"],
"17",If(HourValue1.Selected.Value=HourValue2.Selected.Value,
Switch(MinuteValue1.Selected.Value,
"00",["10","20","30"],
"10",["20","30"],
"20",["30"],
[""]),
["00","10","20","30"]),
"20",If(HourValue1.Selected.Value=HourValue2.Selected.Value,
Switch(MinuteValue1.Selected.Value,
"00",["10","20","30"],
"10",["20","30"],
"20",["30"],
[""]),
["00","10","20","30"]),
If(HourValue1.Selected.Value=HourValue2.Selected.Value,
Switch(MinuteValue1.Selected.Value,
"00",["10","20","30","40","50"],
"10",["20","30","40","50"],
"20",["30","40","50"],
"30",["40","50"],
"40",["50"],
[""]),
["00","10","20","30","40","50"]))
The formula successfully populated valid entries into the items available in the dropdown. However, it causes the default value to be reset to the first item available, instead of retaining its old value (both Default=Parent.Default, and Parent.Default=ThisItem.EndTime). For example, if I have an existing data, <StartTime=08:30, EndTime=11:30>, upon viewing/editing of it, the dropdowns controlling EndTime actually show 08:40, simply because that's the first valid entry. So it seems that the default value somehow got refreshed/reset due to the change of items property.
So, the question, how can I prevent this behavior, and retain the default value when it is a valid entry?