Skip to main content
Nintex Community Menu Bar

Hey everyone,

 

I'm trying to set a user's manager in Office 365 forms. I've read this Nintex Forms Managers name into people picker  and also I have got this working on premises. I'm wondering if the API is supposed to be included in Nintex now or if I still need to upload the people picker JavaScript file - I don't think the on prem one will work with online how ever?

 

Anyone worked with people pickers in Office 365?

 

Thanks heaps for any guidance

 

John LuangcoChris Ben

Do you mean the UserProfileLookup runtime function (doesn't seem to be available) or the people picker api people picker | Walking the stack (not sure if available or not as I haven't tried to use it in Office 365)?

Would be great if the Nintex moderators could clarify.

In our case we used a slightly different approach in a recent on premise project than what was mentioned in the thread. Basically the client had an employee field and a manager field. The employee field is prepopulated by the logged on user, but the user has the option to change it. This should then prepopulate the manager field with the manager of the user in the employee field but allow the user to also overwrite the manager.

This requirement meant using the UserProfileLookup runtime function was not suitable as this function runs when the submit button was clicked. In this case we:

  • used added and removed function in the people picker api to detect when the employee field was changed
  • we then used sp services to look up the manager of a user
  • used the people picker api to prepopulate the manager field

To clarify, I mean the people picker API Developing against the new people control in Nintex Forms | Walking the stack  - I can get the users manager fine, just need to populate the people picker control. I asked Chris Ben and he asked someone at Nintex that said this should work in Office 365, but not exactly sure where it sits or how to access it .

Thanks for your reply.


Got this working using the add method (search still doesn't work). You do how ever have to do a query to get the manager's email address and display name before hand (I've done this with my custom web service which talks to Azure AD). This adds it to the user control. I also check whether the control already has a value, or it will populate too many times.

if (NWF$('.jsLeaveApprover .ip-item > span > div').length === 0) {

     var getUserField = new NF.PeoplePickerApi('#' + jsLeaveApproverID);

     getUserField.add({ value: managerEmail, label: data.displayName, type: "user", email: managerEmail });

}

Let me know if any questions.


You have to pass the query to the user profile service through the SharePoint cross site libraries.  Check this out:

// Obviously, before you can do this you need to make certain that all the right SP libraries are loaded:

NWF$.getScript(scriptbase + "MicrosoftAjax.js").then(function (data) {
return NWF$.getScript(scriptbase + "SP.Runtime.js");
}).then(function (data) {
return NWF$.getScript(scriptbase + "SP.js");
}).then(function (data) {
return NWF$.getScript(scriptbase + "SP.RequestExecutor.js");
}).then(function (data) {
var executor = new SP.RequestExecutor(appweburl);

/* here is the call to get the manager */

var url = appweburl + "/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='Manager')?@v='i%3A0%23.f%7Cmembership%7Cchris.clements@xxxxxxxxxx.com'";    //urlEncoded AccountName
var requestHeaders = { "accept": "application/json;odata=verbose" };

executor.executeAsync({
url: url,
contentType: "application/json;odata=verbose",
method: "GET",
headers: requestHeaders,
success: function(data){
      // The manager will come back in the format of an Office 365 Account Name like  this: 'i:0#.f|membership|user%domain.onmicrosoft.com'
var d = data;
},
fail: function(error){

var e = error;
},
error: function(error){

var e = error;
}
});

}


Hi Rebecca,

I'm using Nintex for Office 365. And your solution is still giving me the below error. Any thoughts on this?.

Error: "NF.PeoplePickerApi is not a constructor"

Thanks.


Hi Jatin,

Sorry this was years ago - can you link your code? It's possible the APIs have changed since I last used this .

Cheers


Hi Rebecca,

I'm doing exactly what you have done. And also as mentioned by many Nintex users. Few are saying that PeoplePickerApi is not present for Nintex for Office 365.

var getUserField = new NF.PeoplePickerApi('#' + pplTestUser);
getUserField.add({ value: user1@ourdomain.com, label: User1 displayName, type: "user", email: user1@ourdomain.com });

As you said, it is possible that Api must have changed. But I could not find the updated API anywhere. It would of great help if you help me with this.


Not sure if this is still an issue, but see this post for adding the People Picker API to your sharepoint site.

https://community.nintex.com/t5/Nintex-for-Office-365/Unable-to-get-PeoplePickerAPI-to-work/m-p/12991#M1640

 


Reply