Showing results for 
Search instead for 
Did you mean: 

Get Manager with connected People fields using JavaScript

Nintex Newbie
1 2 756

I was trying to find a simple way to get an Employee's Manager in a People field on a form.  You can use a Calculated Field to display the Manager but I couldn't connect that directly to a People column.  Also, in some cases, the Manager a person reports to is not always the Manager in their User Profile, so I wanted to give users the ability to select the appropriate manager as an alternative option. I found a few posts that used JavaScript to do this, but they seemed needlessly complicated.  I used People Picker Extensions and JavaScript events in Nintex Forms as references and came up with a simpler solution (also, I'm using Nintex Forms Enterprise version 

First, I added a People Field for the Employee:

  • Formula: Current User
  • Store Client ID in JavaScript variable: Yes
  • Client ID JavaScript variable name: Employee

Employee People Field

Second, I added a People Field for the Manager:

  • Default Value Source: Use connected field's default value
  • Store Client ID in JavaScript variable: Yes
  • Client ID JavaScript variable name: Manager

Manager People Field

Then, I added a Calculated Field to the form with the following attributes:

  • Formula: userProfileLookup(Employee,'Manager')
  • Store Client ID in JavaScript variable: Yes
  • Client ID JavaScript variable name: ManagerLan

Calculated Field

Finally, I added the code into the Custom JavaScript in the form Settings:

NWF.FormFiller.Events.RegisterAfterReady(function() {
   var emp = new NF.PeoplePickerApi('#'+Employee);
      var people = NWF$('#' + Employee).val().split(';');
      if(people.length > 2){

function GetManager(){
      var val = NWF$('#' + ManagerLan).val();
      var mgr = new NF.PeoplePickerApi('#'+Manager);
      if(val.length > 0){
   }, 1000);

The Manager people picker gets populated:

Form Excerpt

Nintex Newbie

Great work!

Nintex Newbie

Is there a way to move the cursor to different field other than Manager text box. 

In my case I would populate employee as current user and manager as current users manager using this approach on form load.

But no matter whatever JS I would try to move the cursor to the first text box(in my case it is title), the cursor always ends up in Manager text box.