Skip to main content

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?

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?


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? 


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(datas0]);
           })
   })
})

‌    ‌ 


Reply