How to Create Persion or Group Column

How to Create Persion or Group Column using JSOM.

Thanks.

June 23rd, 2015 6:56am

Check if below can help you

http://www.codeproject.com/Articles/990131/CRUD-operation-to-list-using-SharePoint-Rest-API

Free Windows Admin Tool Kit Click here and download it now
June 23rd, 2015 7:29am

Hi ,

You can implementation  details  on below link

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

let me know if this helps.

Thanks

Bhism 

June 23rd, 2015 7:41am

Hi,

You can try following code:

<script type="text/ecmascript">
    function addFields() {
          
        var clientContext = new SP.ClientContext.get_current();
        var oWebsite = clientContext.get_web();
        //Geting reference to the list
        oList = clientContext.get_web().get_lists().getByTitle('CustomList');
        
        // Get filed collection
        var fldCollection = oList.get_fields();

        var f1 = clientContext.castTo(
                        fldCollection.addFieldAsXml('<Field Type="User" DisplayName="UserField" Name="UserField" />', true, SP.AddFieldOptions.addToDefaultContentType),
                        SP.FieldUser);
        f1.set_title("Title");
        f1.set_description("sample desc");
        f1.update();

        clientContext.executeQueryAsync(
            Function.createDelegate(this, this.onQuerySucceeded),
            Function.createDelegate(this, this.onQueryFailed)
            );
    }

    function onQuerySucceeded() {
        alert("List Field Updated");
    }

    function onQueryFailed(sender, args) {
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    }

</script>

I have used following link and made some changes:

http://www.codeproject.com/Articles/561309/AddplusFieldsplustoplusSharePointplus-plusListp

Free Windows Admin Tool Kit Click here and download it now
June 23rd, 2015 8:40am

Hi Sriram,

From your description, my understanding is that you want to create people picker with JSOM.

Please refer to this code below:

<div id="peoplePickerDiv"></div>
<script type="text/javascript" src="/_layouts/15/clienttemplates.js"></script>
<script type="text/javascript" src="/_layouts/15/clientforms.js"></script>
<script type="text/javascript" src="/_layouts/15/clientpeoplepicker.js"></script>
<script type="text/javascript" src="/_layouts/15/autofill.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.core.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script>

<script type="text/javascript">

    // Run your custom code when the DOM is ready.

    $(document).ready(function () {

        initializePeoplePicker('peoplePickerDiv')

    });


    // Render and initialize the client-side People Picker.

    function initializePeoplePicker(peoplePickerElementId) {


        var schema = {};

        schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';

        schema['SearchPrincipalSource'] = 15;

        schema['ResolvePrincipalSource'] = 15;

        schema['AllowMultipleValues'] = true;

        schema['MaximumEntitySuggestions'] = 50;

        schema['Width'] = '280px';


        this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);

    }

</script>

The screenshot below is my test result:

For reference:

https://social.msdn.microsoft.com/Forums/office/en-US/d64632d5-fa39-4d7c-8afe-4b74fb966d14/add-new-row-with-peoplepicker?forum=sharepointdevelopment

Best Regards,

Vincent Han

June 24th, 2015 3:30am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics