In this post I’ll demonstrate how to select the current logged in user, by default, in Microsoft PowerApps.
This post is about a hidden List of SharePoint, User Information List. In this, the items are the active Office365 users, that have some interaction with this site. For ex. if a user has visited the site, or, the user has been marked in one of the List [like assigned a Task] of the site, or, the user is the administrator then, the user gets automatically added to this List.
By default, the site’s administrator is the only added user to this List. So, if you assign say, a task, to an active user from the Office365 user panel, then, SharePoint automatically adds the user in the User Information List. In my one of the earlier post, https://realmpksharepoint.wordpress.com/2014/01/19/update-a-usermulti-column-value-in-client-object-model-c/, I had demonstrated how to update a UserField SiteColumn say, Attendees for a Calendar item[meeting], with the user id from the web’s SiteUsers. However, we only get the users from the User Information List as the SiteUsers in CSOM.
So how to add a new active user to this List using CSOM? The answer is the EnsureUser method.
It adds the valid user to the site if it’s not already added.
User user = clientContext.Web.EnsureUser("Piyush Singh"); clientContext.Load(user); clientContext.ExecuteQuery();