Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClientPeoplePicker in CustomForm

I have Calendar and have a few customer fields and taking the input through a custom form. As the custom form defaults to using SharePoint:FormField for people picker; I have included the ClientPeoplePicker using the following

<SharePoint:ClientPeoplePicker Required="true" ValidationEnabled="true" ID="peoplepciker"  runat="server" AutoFillEnabled="True" VisibleSuggestions="3"  Rows="1" AllowMultipleEntities="false"  CssClass="ms-long ms-spellcheck-true" Height="85px" />

Could anyone please advise as to how I can 'link'/bind the output of this peoplepicker to the field in the calendar list?

I am using SP_Designer2013 and SharePoint client only and do not have access to the backend/server in any other shape/form.

Any help is highly appreciated.

Thank you

like image 568
Vishwa Avatar asked Apr 14 '14 13:04

Vishwa


People also ask

What is the client-side people picker control in SharePoint?

What is the client-side People Picker control in SharePoint? The client-side People Picker control lets users quickly search for and select valid user accounts for people, groups, and claims in their organization. The picker is an HTML and JavaScript control that provides cross-browser support.

How do I configure the spclientpeoplepicker?

You can use SPClientPeoplePicker properties to configure the picker with control-specific settings, such as allowing multiple users or specifying caching options. The picker also uses web application configuration settings such as Active Directory Domain Services parameters or targeted forests.

What interface does clientpeoplepicker inherit?

type ClientPeoplePicker = class inherit WebControl interface IValidator interface IPostBackDataHandler Public Class ClientPeoplePicker Inherits WebControl Implements IPostBackDataHandler, IValidator

How to set the people picker field by default in SharePoint?

How to set the people picker field by default with some user eg. Current SharePoint User First of all get current user display name using below code: Set this user as default user for people picker control: Possible scenario when you don't want user to change its default value: Make control non-editable:


1 Answers

I know this is probably too late for you but I was looking for the answer to this as well and thought I'd share my solution.

Old Control

In my new form I had a control that I wanted to replace with the ClientPeoplePicker.

<SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="New" FieldName="Person" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Person')}"/>

New Control

The new ClientPeoplePicker only needs the same id attribute as the control that I wanted to replace.

<SharePoint:ClientPeoplePicker runat="server" id="ff2{$Pos}" />

Edit

I found a forum that listed some of the control's attributes and thought I'd post them for whomever should stumble upon this question.

http://social.msdn.microsoft.com/Forums/en-US/1bd323bf-a009-446b-aac5-e2b9ebde1a07/sharepoint-client-people-picker-allowing-multiple-entries

<SharePoint:ClientPeoplePicker
        Required="true"
        ValidationEnabled="true"
        ID="pplPickerSiteRequestor"
        UseLocalSuggestionCache="true"
        PrincipalAccountType="User"
        runat="server"
        VisibleSuggestions="3"
        Rows="1"
        AllowMultipleEntities="false"
        CssClass="ms-long ms-spellcheck-true user-block"
        ErrorMessage="*" 
/>

<asp:CustomValidator 
        ID="cvpplSiteRequestor" 
        runat="server" 
        ControlToValidate="pplPickerSiteRequestor" 
        ForeColor="Red" 
        ClientValidationFunction="CheckSiteRequestor" 
        ErrorMessage="User is a required field"
        ValidationGroup="SiteAccessForm"
        Text="*">
</asp:CustomValidator>


function CheckSiteRequestor(sender, args) {
    args.IsValid = false;
    var userCount = $("span.ms-entity-resolved").length; //Returns the userNames Count 

    if (userCount === 1) {
        args.IsValid = true;
    }
}
like image 193
MiniRagnarok Avatar answered Sep 25 '22 11:09

MiniRagnarok