Nintex Forms Managers name into people picker

  • 4 November 2014
  • 17 replies
  • 214 views

Badge +3

Is there anyway to specify either the current users, or a person selected in a people picker, Manager is a people picker field on a form?

 

From what I can see it doesn't look like the default value for people picker fields will let you use the 'userProfileLookup' runtime function which would be perfect.  The default value also will not let you use workflow variables for some reason?

 

Does anyone know an easy work around to get that working?

 

P.S.
I can easily populate a calculated field with a users manager, this question is specifically about populating a people picker field with this value.  We have numerous employees that report to multiple people so we'd like to allow the employees to change the specified manager if needed.

 

Thanks.


17 replies

Badge +9

Hi Nick,

look at the article Developing against the new people control in Nintex Forms from Tom Shirley. I use this api to populate a People Picker Control with the manager name of another People Picker Control in the form.

http://walkingthestack.com/2014/04/08/developing-against-the-new-people-control-in-nintex-forms/

Best Regards

Manfred

Badge +3

I don't see exactly how you can use those functions to return the manager?  I see how you can set the people picker, but can you use the search function to find the manager?

Also how would you get it to run when the form is loaded and again if the people picker field is changed?  The article only talks about running it on form load. 

Thanks. 

Badge +9

Hy Nick

In the form settings You have to include the following javascript files in the advanced section:

  1. SPServices from https://spservices.codeplex.com/
    You’ll need to make a slight adjustment to extend the NWF$ object, see http://thechriskent.com/2013/08/08/use-spservices-in-nintex-forms-2010/
  2. FillPeoplePicker.js as seen attached

In my Form I have to People picker controle, one with css class antragsteller and default value 'Current User', another with css class 'manager-control'. When the form is loaded, the manager of the current user will populated to the control manager-control. If you delete the name in the first control, the manager name will also be deleted. When You enter a new name in the first control, the manager name will populated to the manager-control.

Best Regards

Manfred

Userlevel 5
Badge +12

Here is a pretty good link on how to use Javascript to accomplish this: Nintex Forms: Automatically populating the new people picker control - Wow, So SharePoint, Much information

Userlevel 5
Badge +12

You asked for an easy solution, and although the Javascript isn't terribly complicated, maybe you could use this as an alternative:

1) Use a calculated field as you mentioned - this was really easy.    Next to the calculated field have a check box that says "Change Manager".


2) If they click on the check box, hide the calculated field using a simple built in rule.

3) Have a rule that displays a People Picker from which they can now select a new manager.

You should very easily be able to determine which manager they want to use within the workflow by simply seeing if the checkbox is selected or not.

Thanks

Badge +3

Thanks to both of you for the information and alternatives!  Yeah since the javascript solution also requires SPServices I'd really rather stay away from that from a long term maintainability standpoint.  This will be the method that we publicize to our site owners to use so I want to keep it as simple and maintainable as I can.  So I think we'll go with the checkbox method.

The fact that you can't use rules to set field values has probably been the biggest complaint we've had as we switch from InfoPath to Nintex forms.  Hopefully it's a feature that is coming soon!

Userlevel 5
Badge +12

Great to hear and glad to help, I'd mark this one as resolved.

Badge +3

Hi All,

This is also something that we are trying to do. An interesting thing I learnt recently from Anthony Sopkow is that you are "actually able to pass a value from a formula control over to a custom JavaScript function from within the calculated field". Re: Using Nintex Form Runtime Lookup Function to populate a textbox

This gave me a thought that we can use the runtime function together with the new people picker api to:

  • make use of the runtime function called userProfileLookup to get the manager of a the user from my first people picker and run a custom javascript function whilst passing the manager value into the function. 2014-12-15_1437 - JohnLuangco's library
  • use the new people picker api to populate the second people picker field for the manager by attaching a client ID javascript variable name to the field so that it can be located by the custom function 2014-12-15_1438 - JohnLuangco's library

Custom JavaScript Function (Replace PS with your own domain)

function setManager(value){

    var processedUserName = value.replace("PS\","");

    var ins = new NF.PeoplePickerApi('#'+ manager_id);

    ins.search('PS\'+processedUserName).done(function (data) {

    ins.add(data[0]);

  });

}*/

This seems to work well, however I notice that the formula control will call the javascript function twice which then causes the manager to be populated twice in the people picker. Does anyone have any suggestions on how to prevent this?

Thanks

John

Badge +3

Hi Pramod,

Thanks for your suggestion. 2014-12-15_1506 - JohnLuangco's library 

That's something to think about so that the manager doesn't keep getting added when people view or edit a submitted form. My current problem revolves around the manager being added twice on the new form (before it gets submitted).

Userlevel 5
Badge +12

John,

What about: Put a simple IF condition inside of your function to make sure it only fires once. This could be something as simple as an incremented int value to check against to see if it already fired.

-Mike

Badge +3

Thanks Mike. I did try to put a catch in there so that it only fires once. However what I found was that the function is called and run at the same time as opposed to running in a linear fashion. Might ask Nintex to see if this approach is supported.

Badge +1

I know this is late, but we have had a very similar issue, and got around it without JS.  There are probably caveats around how we did it, but it works, and that's all that matters to me grin.png.

It's all around not requiring to have a people picker control to connect to the list item directly, but rather a calculated control calculating the boss name from the people picker control (using userprofileLookup).  It is then connected to the text item, and most importantly is that the workflow works on the value in the connected text item.

Badge +2

Here is how I did it....

  1. Add a Calculate Value to the form, and create a rule to hide it.
  2. Add this formula to the Calculated control: userProfileLookup( userProfileLookup(  Current User, "Manager"), "PreferredName")
  3. Add the javascript below to the form, change the control IDs (peoplecontrol, calculatedvaluecontrol) to your controls.
  4. The 750ms delay gives the Calculated control enough time to make the 2 userProfileLookup calls, 750 was a safe number and is not perceivable by users. You may have to increase it if you have a slow network, test test test.

 

NWF$(document).ready(function()

{

   NWF.FormFiller.Events.RegisterAfterReady(function()

    {

     setTimeout(function(){  

     var ins = new NF.PeoplePickerApi('#' + peoplecontrol);

     var currentuser = NWF$('#' + calculatedvaluecontrol).val();

     ins.search(currentuser).done(function (data)

     {      

        ins.add(data[0]);

      });

}, 750);

Badge +3

you are missing the closing:

});

});

in your statement. Also how are you handling the function firing every time the user enters edit mode?

Badge +2

In our situation that was not an issue because the control was only visible during New mode.

Badge +2
Dear Community Members,
I'm developing a Nintex form that requires approval from the requester's 1st, 2nd and 3rd level manager as in the org chart (mysite). I'm using calculated fields on the form to look up for the 1st level Manger of requester and subsequesntly the manager of 1st level manager and so on. With this I'm able to populate all 3 approvers in the form.
 
But I'm wondering if this would be a robust solution for a long run. Are there are any known issues or glitches that could arise from using Calculcated field(connected to Single text SP columns) to hold the approvers to be used in workflow.
Any advise or suggestion is appreaciated.
Thanks in advance!
 
PS : Sorry, I didn't know where is the option to begin a new conversation and in need of urgent advice.
Userlevel 5
Badge +14

@jothi, to start new question thread, select a proper forum for your question from left toolbar

 

3706i2C800D369CB5BA3C.jpg

 

and then there is a 'Create a post' button below list of recomended videos

 

3707i55702CA9800F0494.jpg

Reply