cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
julianknight
Nintex Newbie

Cannot find a successful way to access user profile details in forms

I've been trying all the ways I can find to access the currently logged in users profile details from Nintex forms for Office 365. It is driving me mad.

Nothing I've tried works.

The closest I've got is to be able to load SPServices - I can return the version number just fine. But when I try to access any data, I always get a blank response.

For example, with this in the form's custom JS:

NWF$(function(){      console.log('##### ======= START HERE ======= #####');       console.log(NWF$().SPServices.Version());       var userAccount = NWF$().SPServices.SPGetCurrentUser({           fieldName: "Title",            debug: false      });      var userName = NWF$().SPServices.SPGetCurrentUser({           fieldName: "UserName"      });      var thisSite = NWF$().SPServices.SPGetCurrentSite();       console.log('USER ACCOUNT: ',userAccount);      console.log('USER NAME: ',userName);      console.log('SITE NAME: ',thisSite);      alert('SITE NAME: '&thisSite);            NWF$().SPServices({           operation: "GetUserInfo",           async: false,           userLoginName: NWF$().SPServices.SPGetCurrentUser(),           completefunc: function (xData, Status) {                NWF$(xData.responseXML).find("User").each(function() {                     alert(NWF$(this).attr("Name"));                });           }      });            console.log('##### ======= FINISH HERE ======= #####'); });

Each of the variables comes back blank and the final part is never shown so it presumably fails.

I've also tried directly accessing the data using JSOM by adding the following to the custom JavaScript includes:

https://nhsengland.sharepoint.com/_layouts/15/init.js

https://nhsengland.sharepoint.com/_layouts/15/sp.runtime.js

https://nhsengland.sharepoint.com/_layouts/15/SP.js

https://nhsengland.sharepoint.com/_layouts/15/SP.UserProfiles.js

And the following custom JavaScript:

NWF$(function(){      console.log('##### ======= START HERE ======= #####');       // ensure that the SP.UserProfiles.js file is loaded before the custom code runs.      SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, 'SP.UserProfiles.js');     var userProfileProperties;       function getUserProperties() {         var clientContext = new SP.ClientContext.get_current();         var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);         userProfileProperties = peopleManager.getMyProperties();           console.log(userProfileProperties);         clientContext.load(userProfileProperties);         clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);     }       // This function runs if the executeQueryAsync call succeeds.     function onRequestSuccess() {         if (userProfileProperties.get_userProfileProperties()['Title'] != "")             console.log( userProfileProperties.get_userProfileProperties()['Title'] );     }       // This function runs if the executeQueryAsync call fails.     function onRequestFail(sender, args) {         console.log('REQUEST FAILED');     }            console.log('##### ======= FINISH HERE ======= #####'); });

But that always fails.

Surely there must be some way of accessing the user profile details?!?! Please help!

Labels: (1)
Reply
15 Replies
christopheraucq
Nintex Newbie

Re: Cannot find a successful way to access user profile details in forms

Hi Julian,

Maybe this post can help.

This is not exactly what you need but it gives a direction.

Regards,

Christophe

Reply
julianknight
Nintex Newbie

Re: Cannot find a successful way to access user profile details in forms

Thanks Christophe! I have made a little progress. Following that post, I managed to get the permission value back. However, I still can't get the user profile data. So I'm wondering if I'm missing something on the JSON side now. Good grief, surely other people do this stuff? How can it be so difficult!

Reply
julianknight
Nintex Newbie

Re: Cannot find a successful way to access user profile details in forms

Having done further research, here are my current findings and it isn't pretty.

As far as I can tell, it isn't currently possible to call anything from /_layouts/15/SP.UserProfiles.js as it is never activated though I can see it being loaded by FormsPart.aspx. No matter how you then try to call it from your custom JS, it will never work. If you wrap the call in "SP.SOD.executeOrDelayUntilScriptLoaded(loadProfileData, 'SP.UserProfiles.js');" the script is never executed. If you try to call it without that, it always fails.

You CAN call get_current()/get_web()/get_currentUser() but that only gives you access to limited information and not the full profile.

I can only think that this relates to the structure of Nintex Forms and the complex way things are loaded. e.g. the SP files are loaded by FormsPart.aspx but the form code is run from NFLaunch.aspx. I'm also guessing that this is the reason that the user profile function available to on-prem users is not made available to Office 365 users.

Unless someone can find an alternative method, I'm afraid this makes Nintex Forms extremely limited except purely for use in Workflows - Even InfoPath can be made to lookup user profile information! Looks like we will be looking elsewhere for a tool that will support us.

Very disappointing.

Reply
christopheraucq
Nintex Newbie

Re: Cannot find a successful way to access user profile details in forms

Julian,

Which user's info are you searching for?

Christophe

Reply
julianknight
Nintex Newbie

Re: Cannot find a successful way to access user profile details in forms

Initially:

  • Department
  • Team
  • Work Email (these users are not using Exchange Online)
  • Phone Number
  • The users manager - for which I will then need to lookup the managers contact details.

These need to be from the SharePoint Online User Profile service not from AAD.

Reply
christopheraucq
Nintex Newbie

Re: Cannot find a successful way to access user profile details in forms

Julian,

Maybe you can use the Workflow Query User Profile action

Regards,

Christophe

Reply
julianknight
Nintex Newbie

Re: Cannot find a successful way to access user profile details in forms

Thanks for the suggestion Christophe. I didn't really want to have to use a workflow to populate that data but rather to have it populate when someone opens the new form. I'm sure I can update the data using a workflow & I may have to resort to that but it means that the person filling in a new form cannot see whether the data is correct as they are filling it in. Not really a very good UX.

This should be easy and MS provide the helper libraries to make it happen in the front-end. It would be easily fixed if Nintex made the libraries available to the forms app.

0 Kudos
Reply
patrickabel
Nintex Newbie

Re: Cannot find a successful way to access user profile details in forms

Julian Knight​ It looks like our community has several unanswered questions surrounding this topic for those of us using O365.

I've pulled this data before using REST in a SharePoint add-in with custom jQuery, but never within the context of a Nintex Form. I'll see if I can dabble with this and find a workaround until the on-prem user profiles are supported here as well.

Reply
Not applicable

Re: Cannot find a successful way to access user profile details in forms

Patrick Abel​, that's a good catch. I'll see if we can get a TE to respond or post a blog to address the questions.

Meantime, we did just upgrade Forms with User Profiles if that helps. What's New From Nintex! April 2016 Release

Thanks!

Frank

0 Kudos
Reply