Hi friends, In this tutorial, we are going to learn how to fetch the current username and set its value to any SharePoint field. To get the current SharePoint user information we can use SPServices.
There is one utility function of SPServices called SPGetCurrentUser which has the functionality to return information about the current user.How $().SPServices.SPGetCurrentUser works?
The SPGetCurrentUser function does an AJAX call to grab /_layouts/userdisp.aspx?Force=True and "scrapes" the values from the page based on the internal field name (aka StaticName).How to get Current User Name and Set it to SharePoint field?
- Open your list new item page.
- Click on Settings button (Gear icon) and click on Edit page.
- Add Content Editor Web Part.
- Copy the following code and paste it in above Web Part.
- Click on Stop Editing and it's done!
<div> <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script src="http://www.myclassbook.org/wp-content/uploads/2016/07/jquery.SPServices-2014.02.min_.js"></script> <div> <script language="javascript" type="text/javascript"> $(document).ready(function() { // Set the "Full Name" input field to the current user's "Title" property var userName = $().SPServices.SPGetCurrentUser({ fieldName: "Title" }); $("input[Title='Full Name']").val(userName); }); </script> </div> </div>
Now whenever you open the page for adding a new item in the SharePoint list, you can see the name of the current user is auto-populated in the Full Name field. See the screenshot below.

If you like this article, please share it with your friends and like our facebook page for future updates. Subscribe to our newsletter to get notifications about our updates via email. If you have any queries, feel free to ask in the comments section below. Have a nice day!

If you like this article, please share it with your friends and like our facebook page for future updates. Subscribe to our newsletter to get notifications about our updates via email. If you have any queries, feel free to ask in the comments section below. Have a nice day!
2 Comments
AstrHori's new fully-manual lens offers a roughly 32mm equal area of view with an F5.6 aperture. Boston, Massachusetts-based media company Above Summit created this 'Seasonlapse' showcasing year-round transitions from variety of the} most scenic locations of their hometown. Lensrentals sends moisture wicking underwear plenty of gear out to customers, and generally the gear returns with injury. In model new} weblog post, Lensrentals shares frequent ways in which cameras and lenses are damaged and destroyed. At this year's Adobe MAX, Adobe has introduced new options throughout its suite of photo modifying purposes, together with Lightroom, Photoshop and Adobe Camera Raw. The new variations add main new AI options to make modifying your pictures easier than ever.
ReplyDeleteAnd while mBitcasino works 카지노사이트 with various sport developers, all gameplays are truthful since they supply gamers a fair chance to win massive using tried-and-true strategies. It is generally really helpful that gamers ought to keep away from playing with money they can not afford to lose. Bankroll administration helps gamers by preserving them from going broke and stopping them from chasing their losses. By setting guidelines, limits, or boundaries for themselves forward of time, it’s much less doubtless that a player will go into the pink after dropping periods. To see if playing is authorized in your nation, have the ability to|you presumably can} check by way of your country’s legislation. Gambling licenses are granted by the federal government where the casinos operate.
ReplyDelete