set peoplepicker to user other than current user

  • 22 August 2017
  • 5 replies
  • 10 views

Badge +3

I am trying to set a people picker control to a user other than the current user. I have read the 1222 post and am unable to get that to work: https://community.nintex.com/docs/DOC-1222

I put this function in my custom JavaScript:

function setToPrimay() {

 var ins = new NF.PeoplePickerApi('#' + 'cidRep');
 ins.search('i:0#.w|xxxuserID').done(function (data) {
  ins.add(data[0]);
}

The people picker Client ID JavaScript variable name is: cidRep.

The button has a client click of: NWF.FormFiller.Events.RegisterAfterReady(function () { setToPrimay(); });

(Of course I changed the domain and user ID above)

I also tried setting the people picker with no luck: NWF$("#"+cidRep).val('i:0#.w|xxxuserID');

Thanks for any assistance,

John


5 replies

Userlevel 5
Badge +14

- remove apostrophes from around cidRep javascript variable

- configure button click just to: setToPrimary();

Badge +3

Thank you for your response Marian, I really appreciate it!

I have updated the JS code, removing the quotes around the people picker client ID and striped the client click down to just the function call and a semi colon. I also put a line in to test for the ins object but I never even got an alert popup and the people picker didn't get populated. If I manually paste the same i:0#w|xxx/userID in the people picker the user comes up.

Badge +3

I just noticed a typo in the function name. I updated that and still am not getting the people picker populated.

Updated function:

function setToPrimary() { 
   var ins = new NF.PeoplePickerApi('#' + cidRep);
   ins.search('i:0#.w|xxxuserID').done(function (data) {
      ins.add(data[0]);
   }
}

Userlevel 5
Badge +14

try with user identifier as follows

i:0#w|xxx\userID

Badge +3

I also had a missing closing paran, but you got me there. Thanks a ton Marian!

function setToPrimary() {
   var ins = new NF.PeoplePickerApi('#' + cidRep);
   ins.search('i:0#.w|xxx\userID').done(function (data) {
      ins.add(data[0]);
   })<-----
}

Reply