Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

SharePoint 2013 and people picker javascript : how to allow to choice only one user and not multiple value?

$
0
0

Hello,

I have a custom C# aspx page that was created to be used inside of SharePoint 2013. It uses this  people-picker.

https://msdn.microsoft.com/en-us/library/office/jj713593.aspx

I would like to not allow the multiple Value.. it is possible ?

I would like when user resolve one user , he cannot add another user into the people picker

 if i change the  schema['AllowMultipleValues']=true; to  schema['AllowMultipleValues']=false; i will just display a red message but user will be able to add another user and another user without end into the people picker.

How can i fix this?

Thanks

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %><%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %><%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %><%@ Import Namespace="Microsoft.SharePoint" %><%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Product.aspx.cs" Inherits="Product" %><html dir="ltr"><head runat="server"><meta name="WebPartPageExpansion" content="full" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Product</title><meta http-equiv="X-UA-Compatible" content="IE=10" /><link rel="stylesheet" type="text/css" href="/_layouts/15/1033/styles/Themable/corev15.css"/><script src="http://code.jquery.com/jquery-1.12.2.min.js" type="text/javascript"></script><SharePoint:ScriptLink name="microsoftajax.js" runat="server" LoadAfterUI="true" Localizable="false" /><SharePoint:ScriptLink name="init.js" runat="server" LoadAfterUI="true" Localizable="false" /><SharePoint:ScriptLink name="sp.init.js" runat="server" LoadAfterUI="true" Localizable="false" /><SharePoint:ScriptLink name="core.js" runat="server" LoadAfterUI="true" Localizable="false" /><SharePoint:ScriptLink name="clienttemplates.js" runat="server" LoadAfterUI="true" Localizable="false" /><SharePoint:ScriptLink name="clientforms.js" runat="server" LoadAfterUI="true" Localizable="false" /><SharePoint:ScriptLink name="clientpeoplepicker.js" runat="server" LoadAfterUI="true" Localizable="false" /><SharePoint:ScriptLink name="autofill.js" runat="server" LoadAfterUI="true" Localizable="false" /><SharePoint:ScriptLink name="sp.js" runat="server" LoadAfterUI="true" Localizable="false" /><SharePoint:ScriptLink name="sp.runtime.js" runat="server" LoadAfterUI="true" Localizable="false" /><SharePoint:ScriptLink name="sp.core.js" runat="server" LoadAfterUI="true" Localizable="false" /><script type="text/javascript">
    $(document).ready(function () {

        // Specify the unique ID of the DOM element where the
        // picker will render.
        initializePeoplePicker('peoplePickerDiv');
    });

    // Render and initialize the client-side People Picker.
    function initializePeoplePicker(peoplePickerElementId) {

        // Create a schema to store picker properties, and set the properties.
        var schema = {};
        schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
        schema['SearchPrincipalSource'] = 15;
        schema['ResolvePrincipalSource'] = 15;
        schema['AllowMultipleValues'] = true;
        schema['MaximumEntitySuggestions'] = 50;
        schema['Width'] = '280px';

        // Render and initialize the picker.
        // Pass the ID of the DOM element that contains the picker, an array of initial
        // PickerEntity objects to set the picker value, and a schema that defines
        // picker properties.
        this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);
    }
</script><style type="text/css">
    .sp-peoplepicker-topLevel{
        height:auto !important;
    }</style></head><body><div id="peoplePickerDiv"></div></body></html>



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>