Display current logged in User in a SharePoint Page or Form - Fabian Neve

About SharePoint, Office 365, and other technical stuff

Monday, October 9, 2017

Display current logged in User in a SharePoint Page or Form

If you like to show the current logged-in User in a Page or a Form (eg. NewForm.aspx), you can use following JavaScript code. Insert it via script editor/code snippet and don't forget to reference a Javascript file (<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>).

With that code, you can insert the Username into a div with the ID "welcome" (choose any ID you want, just change it in the script).

I used that code for a NewForm.aspx, the goal was to display the current User on top of the form. So I added folllowing HTML after the javascript code:


The result will be something like this - just edit the html accordingly: