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

Not able to add Users from People Picker using ECMA script

$
0
0

Hi,

I have written below ecma script to add multiple users from people picker.

But the problem is I am facing is,only one user is getting added into the group i.e. 

If I add user1,user2 only user2 is getting added into the group.

Please let me know if I am missing anything here.

$('#peoplePickerDiv .sp-peoplepicker-userSpan').each(function () {

                                                employeeid = $(this).attr('sid').split('\\')[1];

                                                alert(employeeid);

                                                user = clientContext.get_web().ensureUser(domain\\'+ employeeid);

                                               

                                                });          

                var userCollection = Group.get_users();

                userCollection.addUser(user);                  

                clientContext.load(user);

                clientContext.load(userCollection);        

                clientContext.load(Group);           

                clientContext.executeQueryAsync(Function.createDelegate(this, this.onUserAddedSucceeded), Function.createDelegate(this, this.onUserAddedFailed));

Regards,

Sudheer


Thanks & Regards, Sudheer


Viewing all articles
Browse latest Browse all 7589

Trending Articles



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