Forum Discussion
Auto populate person field with current user - InfoPath
It's been awhile and we're no longer using InfoPath so I hope my recollection below is correct. In form load, add a rule that if ID is blank (i.e. new form), set a text field (i.e. CurrentUser) value to equal UserName(). Then set the people picker (AccountID) value to this field (CurrentUser). If I remember correctly, I had to use substring to remove any part of UserName() result to just give me the email address before I could use it as the value for the people picker. Hopefully this helps. If I find a copy of the old xml file, I'll try to post the exact solution.
Yes, that's how I USED to do it, but that's the issue: it does not work anymore.
I tried using both an un-trimmed username() value (e.g. i:0#.f|membership|mboonie@myemailaddress.com) and my plain email, but neither of them caused the people picker to update. Using my old developers' trick of placing calculated controls on the form to display all "hidden" values, I see that the Form Load rules set AccountID, but the DisplayName and the AccountType are still empty (even if I click the Check Name button.)
Again, I'm in Windows 10 using SPO, and this is a browser-enabled, "Form Library form", as opposed to a List form; but this function no longer works in any situation for me.