0

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.load(newUser);
            context.executeQueryAsync(function () {
                },

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

                    getAssignedToUserIdByEmail(users[0].EntityData.Email);


                    visitorIDs = ResolvedToUser.Id;
                    visitorIDs.push(ResolvedToUser.Id);

                }, 100);

        };


1 Answer 1

1

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:

visitorIDs.push(ResolvedToUser.Id);

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 and acknowledge you have read our privacy policy.

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