I should be able to have figured this out on my own but I've spent far too much time now trying to figure this out on my own. Any search results found either are just different enough they don't apply or doing what is suggested doesn't resolve my challenge.
Oh well.
Here goes:
Simple datacard on a form that works. It just doesn't save/update this column correctly.
DC1.Default = ThisItem.Status (meaningless since the form resets and opens in FormMode.New anyway)
Dropdown_Status.Items = Choices([@'SPIFF - Approvals'].Approver) (this populates correctly and if the user was actually making a selection, I'd filter it. But this too is meaningless as we'll soon see.)
Dropdown_Status.DefaultSelectedItems = User() (This seems like it should work. When looking at the statement in the IDE, it shows returning a single record. Myself during unit testing of course)
Dropdown_Status.Default = NULL (Since I'm using DefaultSelectedItems, this seems unnecessary)
But when the form opens in New Mode, of course it ignores that I just realized. So now I think I understand what the actual problem is but not sure the best way to resolve.
Should I put the form in Edit mode on Reset? If I do, should I clear out default values which shouldn't be there?
Update: I tried changing to Edit mode which fails at present because there is no valid record to display/edit. So using the form in New mode seems like the right thing.
I figured it out. Man oh man.
You have to do some funky stuff when you want to autoselect a user in a dropdown. It appears you can't simply use User().
The solution was setting the Default on the datacard to this:
If(
Parent.Mode = FormMode.New,
{
Claims: Concatenate(
"i:0#.f|membership|",
User().Email// Person email
),
Department: "",
DisplayName: User().FullName,
Email: User().Email,
// Person email
JobTitle: "",
Picture: ""
},
ThisItem.Approver
)
I added the If statement because I realized as I was solving this that I will need to provide the ability to modify this record which means opening the form in Edit mode later.
WarrenBelz
146,605
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,946
Most Valuable Professional