I made a custom list, it is actually a form fill out for an absence request workflow. Before publishing it I found a flaw. The first textbox is a Person or Group textbox, this helps out to retrieve the Active Directory username, but the flaw is that I can type whatever username I want, Example:
"User X is logged on, but if he types User Y and hits enter he can request an absence for User Y"
So what I want is, hide the textbox and fill it automatically with the current logged on user.
I've been looking for formulas for the calculated textboxes but I haven't found anything.
I´m not exacly sure what you wan´t to do here but if you have a peoplepicker that you want to fill with the current user, here is how to do that. Then you would have to disable the control in order for the user not to be able to change the value in it.
PickerEntity entity = new PickerEntity
{
Key = SPContext.Current.Web.CurrentUser.LoginName
};
PeopleEditor.Entities.Add(entity);
PeopleEditor.UpdateEntities(PeopleEditor.Entities);
Does this help?
SPUser user = SPContext.Current.Web.CurrentUser;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With