CurrentUser is a powerful built-in object that is available to provide auto-population of various properties of currently logged in user into new/edit form of your content source. The specified properties will be resolved automatically when form loads by end user with currently logged in user’s value for the specific property.
How It Works?
To setup CurrentUser property, Open up Turbo Builder from Site Actions (or settings gear in 2013) and click on edit in the app. Edit any of your new or modify form having single line of text or people of group field. Expand the field settings by clicking on edit as shown in figure below:
That will expand the field and show field settings. Now click on checkbox that says “Enter field value by calculation” and start typing “CurrentUser.” That will show you autocomplete list of properties available for current user object. In below image, you can see, red arrow showing the checkbox for “Enter field value by calculation” checked, black arrow showing the CurrentUser. Typed into textbox and black highlighted is the autocomplete menu of various properties available.
Using Current User in Text Fields
With text fields, you can set any property of CurrentUser, and it will try to resolve and populate that property in page load. For example, if you want to auto populate department of the currently logged in user in some field, you can write CurrentUser.Department and it will be auto-populate it from the active directory value of department attribute.
Using Current User in People or Group field
With people or group field, you have to use CurrentUser.LoginName since that will help turbo form people picker control to auto resolve it.
Other Important Notes
- CurrentUser object support most of the user attributes of active directory, all important properties of SPUser and all properties of User Profile Service if it’s associated with current site collection and accessible to System Account.
- In cases when property do not contain value for specific user, no value will be populated without showing any errors, warning or end user notification.
- In cases when field contains values, entered by end user, it will always take precedence over the calculated value. For example, if end user changes the auto-populated value in new form, and opens the form in edit form, it will show value that is entered by user even if CurrentUser value is set.