ClientPeoplePicker in CustomForm

Vishwa picture Vishwa · Apr 14, 2014 · Viewed 8.5k times · Source

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

Answer

MiniRagnarok picture MiniRagnarok · Aug 27, 2014

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;
    }
}