I am trying to build an array of the ID's of the users in a peoplePicker Field by using push.

So far I'm not having much luck as I'm getting this error:

"Uncaught TypeError: visitorIDs.push is not a function".

My code is below.

I appreciate any suggestions/pointers:

// Get information about all users.
            var users = peoplePickerVisitors.GetAllUserInfo();
            var userInfo = '';
            for (var i = 0; i < users.length; i++) {
                var user = users[i];
                for (var userProperty in user) {
                    userInfo += userProperty + ':  ' + user[userProperty] + '<br>';

            var userloginbase = users[0].Key;
            var userlogin = userloginbase.split("\\");

            var context = SP.ClientContext.get_current();
            var newUser = context.get_web().ensureUser('xxxxxxx\\' + userlogin[1]);
            context.executeQueryAsync(function () {

                function (sender, args) {
                // pause for a second to let the async ensure user complete.
                setTimeout(function() {


                    visitorIDs = ResolvedToUser.Id;

                }, 100);



First of all you need to declare an array at the start of your code/function like:

var visitorIDs = [];

Then in setTimeout function you can use it like below:


So, you need to remove below line from your code which is not necessary:

visitorIDs = ResolvedToUser.Id;

However I am not sure how you are getting ResolvedToUser.Id and your logic for getting all user's IDs from people picker is correct or not.

But above code will help you to resolve your Uncaught TypeError.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.