Set People Name based on other field

  • 25 August 2016
  • 7 replies
  • 11 views

Badge +4

I have two fields in my form:

(a) Direct Manager Name (people picker), e.g. John Smith

(b) Department Head Name (people picker) e.g. John Smith

I also have a check box "If you Direct Manager and Department Head are the same person, check this box". What I want is to copy the Direct Manager name to the Department Head Name field (as this is a mandatory field so I can't leave it blank or rely on the workflow to update this).


Any suggestions?


7 replies

Badge +3

Unfortunately Nintex Forms don't have actions, so there is no way for it to update the item except in a workflow.

You could make the Department Head Name not required if the box is checked in the form. The check box results are 1 for yes, 0 for no.

Then in the workflow, if the box is checked, capture the Direct Manager's Name in a variable (person).

Then populate the Department Head's Name with the variable.

Let me know if you need explanations of how to set up form rules or workflow variables.

Userlevel 5
Badge +14

you can achieve that by javascript using people picker API - People Picker Extensions - Nintex Forms 

have a look on add() function example how to set a value of people picker control. for your case, use as a search() input the value from the other people picker control (direct manager)

Badge +4

Hello Marian - hoping this topic is still being monitored.

Trying to implement a similar solution, dependent upon the value in another control.  This is the code that I'm trying to implement without success.  Can anyone look at this and determine where I've missed something?

 

  1. Dependent Field - Client ID JavaScript variable name + "varSystem"
  2. Dependent Field  value selected - Client ID JavaScript variable name  = "ABC System"
  3. People Picker Field - Client ID JavaScript variable name = "varSystemSponsor"
  4. User Name trying to populate in varSystemSponsor = user.name@domain.com

 

NWF.FormFiller.Events.RegisterAfterReady(function () {
   NWF$('#'+varSystem).change(function(){
     if (NWF$('#'+varSystem + ' input:checked').val() == 'ABC System'){
        var ins = new NF.PeoplePickerApi('#' + varSystemSponsor);
        ins.add(email:"user.name@domain.com");
      }
   })
})

 

Any assistance would be greatly appreciated.

 

Mark

Userlevel 5
Badge +14

ins.add(email:"user.name@domain.com");

this is syntactically not correct, check & follow carefully above posted link.

in a paragraph 'The People Control and using code' you have exact example for your case.

Badge +4

Thank you Marian - I'll give it a shot tomorrow.

After my conditional statement, where I identify the dependent value, I then also had to identify the target field where I wanted to set the value email:email@someone.com

I perhaps mistakenly understood that I would choose one of the 4 format options shown:
ins.add({value:"domain\login", label:"my label value", type:"user", email:"email@someone.com” });

Does that make sense?

Mark

Userlevel 5
Badge +14

yes,you have to provide all the values.

but to make it easier, that's usually done via a search() function. you just need to provide login or mail as it's input and it will look up all the other values

see an example eg here

https://community.nintex.com/message/76653-re-loop-through-people-picker-extension?commentID=76653#comment-76653 

Userlevel 5
Badge +14

here is a working example

NWF.FormFiller.Events.RegisterAfterReady(function () {
    NWF$('#'+varSystem).change(function(){
      var SystemDiv = NWF.FormFiller.Functions.GetFillerDivObjectForControl(NWF$('#'+varSystem).parent()).data('controlid');
      var SystemVal = NWF.FormFiller.Functions.GetValue(SystemDiv,null,'string');
      if (SystemVal == 'Appl'){
         var varSponsorPP = new NF.PeoplePickerApi('#' + varSponsorAppl);
         varSponsorPP.clear();  // remove existing PP content
       
         //  --- option 1 ---
         varSponsorPP.add({value:"dom\MarRoadleyLogin", label:"Mark Roadley Display Name", type:"user", email:"roadley.mark@someone.com" });
       
         //  --- option 2 ---
         varSponsorPP.search("MarRoadleyLogin").done(function(data){
             varSponsorPP.add(data[0]);
         })
      }
    })
})

218815_pastedImage_1.png

Reply