You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$10
For Premium members:
In this article you will learn how to display default value in People Picker Control in List NewForm in SharePoint.
In SharePoint 2010 OnPremise, our customer came up with one new small requirement to show the default value for the people picker control in Custom List OOB New Form. As it was for a simple OOB new form for a Custom List, we analyzed the options accordingly in 2010.
In our case it was SharePoint 2010 and a Custom List OOB New Form. Actually the problem is we cannot set default values for People Picker control from design time so we had two options basically, one with the help of Custom JQuery Injection or second with the help of third party SharePoint Add-On. We observed the following Pros and Cons for the SharePoint Add-On: Pros:
- It can be very useful for setting default values during design time for lookup or people picker fields.
Cons:
- It is not free. Free trial period is only for 30 days. - Setup will install a new wsp to the farm so might be a problem with maintenance or updates in future.
So we decided to go ahead with the first option instead i.e. Custom JQuery Injection approach, that was more simple and quick to implement. For this we edited the default new form for the custom list, then added one Content editor webpart in the form so as to attach a custom .js file with it (Remember there was no JSLink in SP 2010). Now is the time to create actual JQuery file which will inject default value into the People Picker control. In our case Customer wanted to show a particular person’s name in the people picker and not the logged in person as default. If you have the requirement to show the logged in user as default then you may refer this link with some little variation and use of “jquery.SPServices” libraries. We created following JQuery Injection script for our purpose. Here is the custom JQuery script named “setdefaultvalue.js” (I hope you have “jquery.min.js” already available in “_layouts/js” folder in 14 hive, if not you can download it from here and place it in 14 hive path). setdefaultvalue.js
Read more articles on SharePoint:
Getting Started with SharePoint Framework Development using TypeScript, PnP JS, and React JSGetting Started with SharePoint Framework Development using TypeScript, PnP JS, and React JSGetting Started with SharePoint Framework Development using TypeScript, PnP JS, and React JSGetting Started with SharePoint Framework Development using TypeScript, PnP JS, and React JSGetting Started with SharePoint Framework Development using TypeScript, PnP JS, and React JSGetting Started with SharePoint Framewor