cancel
Showing results for 
Search instead for 
Did you mean: 
jonaroy
Nintex Newbie

Loop through People Picker Extension

Jump to solution

I'm trying to figure out, how it's possible to use the PeoplePicker API multiple times. (Add a SP-User from a textfield into the people picker control in a repeating section.)

Following is a sample of my actual code:

function test(){
NWF.FormFiller.Events.RegisterAfterReady(function () {
var $row = NWF$(this);
var rownumb = NWF$('.rows input').val();
var collection = {};

NWF$(".your-repeater .nf-repeater-row:not('.nf-repeater-row-hidden')").each(function (){
var $migrationfield = $row.find(".migrationfield input").val();
for(var i=0;i<rownumb;i++){
collection = new NF.PeoplePickerApi('#' +peoplepicker);
collection.search($migrationfield).done(function (data) {
collection.add(data[0]);
});
}
});
});
}

The problem it returns in the dev-mode is following: 

Uncaught TypeError: cannot read property 'add' of undefined.

So I clearly see that the add method does not work, but why not? Any Suggestions?

Labels: (2)
0 Kudos
Reply
3 Replies
Automation Master
Automation Master

Re: Loop through People Picker Extension

Jump to solution

can you describe your design bit clearer (post a screenshot)?

are both source text box and people controls in repeating section? or just people control?

both on the same row? the same repeating section?

how/where do you call test() function from?

Reply
jonaroy
Nintex Newbie

Re: Loop through People Picker Extension

Jump to solution

Both (the textbox and people control) are in the repeating section. So therefore in the same row as well.
The Test Function gets called by a Button. But later on the function gets called on change. Do you have any idea on how to loop it? 

0 Kudos
Reply
Highlighted
Automation Master
Automation Master

Re: Loop through People Picker Extension

Jump to solution

you do not need any looping at all.

try following

NWF.FormFiller.Events.RegisterAfterReady(function (){
   NWF$('.TxtBoxClass input.nf-associated-control').change(function(){
           var pp = new NF.PeoplePickerApi(NWF$(this).closest('.nf-repeater-row').find('.PPClass input.nf-peoplepicker')[0]);
           pp.clear();
           pp.search(this.value).done(function(data){
              pp.add(data[0]);
           })
   })
})

‌    ‌ 

View solution in original post

Reply