Vadim Tabakman

A little while ago I discovered some Javascript libraries that I found quite easy to use, called SPAPI.  They let you make web service calls to the SharePoint Web Services from Javascript.

You can download the JS libraries here: Download Libraries

The aim is to have a Nintex Form that on load, pulls out some information from the User Profile of the user that is currently logged into SharePoint, and display that information in the form.  Specifically, the Full name, Phone number and Manager.

Here is what our example User Profile looks like:

User Profile

I've manually added a few controls that I will want to update using Javascript, based on information from the web service call.  Here's what the fom looks like :

Basic Form

Javascript Libraries

When you download the SPAPI Javascript libraries, you have a couple of options.  You can copy the JS files to all your servers (I did this because I only have the one server I'm playing with, and I put them in the LAYOUTS folder).

Ideally, store the JS files in a library, like the Styles Library.  Now you can access those JS files from Nintex Forms.

Once you have the files, you simply make a reference to them in your Nintex Form. You do this, but click on Settings in the form, expand the Advanced section and your JS file paths in the Custom Javascript Includes section.

Javascript Includes

Using the Javascript Libraries

To interact with the controls, I find it easy to store each controls' ID in a Javascript variable.  You do this, but opening the settings of each control, expand the Advanced section and turn on the "Store Client ID in Javascript variable" and give it a variable name.

Variable ID

The Javascript part of Nintex Forms is found in the Settings of the form, and more specifically in the Custom Javascript section :

Javascript Settings 

The Actual Javascript Behind the Form

NWF$(function () {
    function getUserProfileInfo() {
        var lists = new SPAPI_Lists('')
        var userprofiles= new SPAPI_UserProfile('')
        var currentUser = userprofiles.getUserProfileByName('');
        if(currentUser.status == 200)
        {
            return currentUser;
        } 
        else
        {
            return null;
        }    
    }
    
    function getPropertyValue(userProfileDoc,propertyName)
    {
        try
        {
          var node = userProfileDoc.responseXML.documentElement.selectSingleNode('//PropertyData/Name[.="' + propertyName+ '"]');
          return node.parentNode.selectSingleNode('Values/ValueData').text;
         }
         catch(e)
         {
            return '';
         }
    }
    function getFullName(userProfileDoc)
    {
        var firstName = getPropertyValue(userProfileDoc,'FirstName');
        var lastName = getPropertyValue(userProfileDoc,'LastName');

         return firstName + ' ' + lastName;
    }

    function getPhone(userProfileDoc)
    {
        var workPhone = getPropertyValue(userProfileDoc,'WorkPhone');
        
        return workPhone;
    }
    function getManager(userProfileDoc)
    {
        var manager = getPropertyValue(userProfileDoc,'Manager');
        
        return manager;
    }

      // Get User Info   
     var userProfile = getUserProfileInfo();
     var userName = getFullName(userProfile);
     var userPhone = getPhone(userProfile);
     var userManager = getManager(userProfile);

    NWF$('#' + varNameID).val(userName);
    NWF$('#' + varPhoneID).val(userPhone);
    NWF$('#' + varManagerID).val(userManager); 
    
});

Result

Once we publish the above form, when you open an instance of that form, it'll make a single web service call and then pull out the information we need.  I've put in some exception handling to cater for when properties don't contain values.

This is what the form will look like, and you can see it auto populated the fields with the data from the User Profile of the current user:

Result Form

Downloads

Form Design: Download Form Design

SPAPI Library: Download

Posted by Vadim Tabakman Wednesday, June 26, 2013 10:42:00 AM Categories: Javascript Nintex Forms User Profiles
Copyright Vadim Tabakman
Rate this Content 0 Votes

Comments

Friday, June 28, 2013 11:16:07 AM

re: Nintex Forms - Querying User Profiles

Hi Vadim,

This is very awesome, thanks for blogging.

Cheers,

Jan

Friday, June 28, 2013 11:32:12 AM

re: Nintex Forms - Querying User Profiles

Thank Jan.  I'm glad you liked it :)

Thursday, July 4, 2013 5:55:28 AM
Anisia Pop

re: Nintex Forms - Querying User Profiles

Hi Vadim,

Great post. I have a question thou: how do you set in this case the value of a people picker field. I have been struggling all day to do that and if I use a class and try to set it something like this NWF$('.userNameIDClass').text(username) then the people picker gets disabled, but if I use val function the people picker never gets filed. Any suggestion is appreciated. Thanks.

 

Best regards,

Anisia Pop

Thursday, July 4, 2013 6:28:45 AM

re: Nintex Forms - Querying User Profiles

Hi Anisia, I'm actually working on this myself. I'll let you know as soon as I figure it out. Vadim
Sunday, July 21, 2013 2:50:21 PM
Mu

re: Nintex Forms - Querying User Profiles

Any Solutions for setting value of people picker field  ?

Tuesday, July 30, 2013 2:46:45 PM
June

re: Nintex Forms - Querying User Profiles

Hi Vadim,

The download link for SPAPI is broken, do you know the new link?

Thanks

June

Wednesday, July 31, 2013 12:04:35 AM

re: Nintex Forms - Querying User Profiles

Hi June,

thanks for bringing that to my attention.  I'll zip them up and put them on my site and update the link tomorrow.

cheers,

Vadim

Wednesday, July 31, 2013 11:19:35 PM
Harsh

re: Nintex Forms - Querying User Profiles

Hi Vadim,

Thanks for this wonderful post but me too are not able to download the JS files from anywhere.

It seems that all links are broken....Please zip them and update the link. 

Thanks 

HArsh

 

 

Wednesday, July 31, 2013 11:28:16 PM
Harsh
Thursday, August 1, 2013 7:06:23 AM
Kate

People Picker

If someone still needs that:

NWF$('.ClassOfThePeoplePickerContorl .ms-inputBox').text(userName);

That might not be the best solution but it works for Nintex Forms 2013. But you still need to click the Button "Check Names". Would be nice if this is also done somehow. Any suggestions?

Thanks

Thursday, August 15, 2013 5:42:21 PM
John Luangco

re: Nintex Forms - Querying User Profiles

Hi

Thanks for the great post. 

Have tried to implement this but seem to be getting errors saying Script from [URL]; was blocked due to mime type mismatch. Could anyone point me to the right direction? 

Thanks in advance

John

Sunday, August 25, 2013 6:16:53 PM
June

Querying User Profiles with Custom Field

Finally got some time to implement this. Works perfect! Thanks for sharing, Vadim :)

One question though, I have some custom fields in User Profile, e.g. Staff Capability. The data stored in it are just "single line text" values. When I try to populate these values on the form, I don't get anything. Has anyone else done this sort of things before?

Thanks

June

Tuesday, September 17, 2013 1:16:19 AM
Pat

re: Nintex Forms - Querying User Profiles

Hi,

I am sorry, but I implement this and nothing in my fields?

Did I miss something? Any help to investigate my code would be appreciated.

Thank you.

Pat

Tuesday, September 17, 2013 6:48:43 AM
Pat

re: Nintex Forms - Querying User Profiles

Yes! It works now. I did not use the right names of the user profil properties!

By the way, I have the same question as Anisia for setting value of people picker field?

Thank you for your help.

Pat

Tuesday, September 17, 2013 8:09:00 AM

re: Nintex Forms - Querying User Profiles

Hi Pat,

Unfortunately, I haven't been able to figure out a way to set a People Picker.  My understanding is that the Forms team will be providing something for that in a future build.

Wish I had an answer for you.

cheers,

Vadim

Wednesday, September 18, 2013 2:28:26 AM
Pat

re: Nintex Forms - Querying User Profiles

Thanks Vadim for your answer.

I still have a problem! Only Sharepoint administrators can see there name and job title "automatically". The others have an error "401 UNAUTHORIZED". It also says "SPAPI_Core is undefined".

What did I miss?

Thank you again for your useful help!

Pat

Wednesday, September 18, 2013 4:06:48 AM
Pat

re: Nintex Forms - Querying User Profiles

Oooops! I don't know if I dare to say it, but it was just a problem of path!!

Sorry for disturbing!

Thanks,

Pat

Thursday, September 19, 2013 3:38:47 PM
Mark Cooley

re: Nintex Forms - Querying User Profiles

Hi Vadim

Thanks for the excellent post. I am using an adaption of this on a list based form. I have a workflow behind the form that requires the from to be updated, as part of that process I overwrite some of the initial values I set.

Is there anyway I can have the code to set initial values for only if the form is new?
Can i query the 'Is New Mode' common property from my javascript?

Cheers
Mark

Friday, September 20, 2013 8:04:11 AM

re: Nintex Forms - Querying User Profiles

Hi Mark,

Great question... wish I knew the answer :).  I'm looking around to see what I can find.

cheers,

Vadim

Friday, September 20, 2013 8:30:23 AM

re: Nintex Forms - Querying User Profiles

Hi Mark,

right now, the only way I can think of to check, is to add a Calculated Value control to the form.  Configure the formula for that control and insert the common property "Is New Mode".

Next, in Advanced, I stored this controls ID in a variable.  I was then able to add a button to my form, made it a Javascript button and in my javascript function, I was able to check the value of the Calculated Value control.

ID stored in : varIsNewMode

Javascript then looks like this :

function fnCheckNewMode()
{
  var myCalcObj = NWF$('#' +varIsNewMode);

  alert(myCalcObj.val());

}

You can then replace the alert and compare it to 'True'.

Hope this helps.

cheers,

Vadim

Tuesday, September 24, 2013 10:43:25 PM
sushank

re: Nintex Forms - Querying User Profiles

Hi,

Gr8 Post.
I am unable to download the SPAPI JS files as both links are broken. Can you share me the JS files on my email id sksmart21@yahoo.com.

Tuesday, September 24, 2013 10:49:00 PM

re: Nintex Forms - Querying User Profiles

Hi All,

I've added a new link to the download section to download the SPAPI library.

cheers,

Vadim

Tuesday, October 1, 2013 2:36:58 AM
Mark Cooley

re: Nintex Forms - Querying User Profiles

Hi Vadim

Thanks for your response.
Unfortunately as my code is firing as the form loads, it is run before the calculated value is evaluated, so this method won't work for what i am trying to achieve.

Cheers
Mark

Tuesday, October 1, 2013 3:25:06 AM
Mark Cooley

re: Nintex Forms - Querying User Profiles

Hi Vadim

After a bit more caffine and some creative thinking I came up with this;

NWF$(document).ready(function(){
   var locPath = NWF$(location).attr('pathname');
   var n = locPath.lastIndexOf('/');
   locPath = locPath.substring(n +1);
   if (locPath == "NewForm.aspx")
   {
      // retrieve user profile values and populate form fields
   }

Result is that the code to populate initial values only runs for a new form ("NewForm.aspx") and not when the form is in Edit mode ("EditForm.aspx")

Cheers
Mark

Tuesday, October 1, 2013 12:18:29 PM

re: Nintex Forms - Querying User Profiles

Very cool Mark!! Thanks a bunch for sharing that.

cheers,

Vadim

Thursday, January 2, 2014 12:23:26 AM
Kanure

re: Nintex Forms - Querying User Profiles

Hi Vadim,

Really very useful post !!

Are you are of any SPAPI which i can use for getting last 30 days data from the 'Site Usage Report' in sharepoint.

Thursday, January 2, 2014 8:15:39 AM

re: Nintex Forms - Querying User Profiles

Hi Kanure,

thanks.  I haven't see a JS api to call the Site Usage Report.  I don't think there's a web service that exposes it.

The only thing I've seen, is getting info from by call the owssvr.dll with a web request like : http://[site]/_vti_bin/owssvr.dll?Cmd=GetUsageBlob&BlobType=Current

But you'd need to figure out how to parse the response you get back.

cheers,

Vadim

Thursday, January 2, 2014 10:19:33 AM
Sydney Nguyen

re: Nintex Forms - Querying User Profiles

Hi Vadim,

 

I am trying to use this for SharePoint 2013 Online but it is not working. Do you have any suggestions?

 

Thanks,

Sydney.

Thursday, January 2, 2014 10:20:34 AM

re: Nintex Forms - Querying User Profiles

Hi Sydney,

I'm afraid I haven't worked with SPO and this web service sorry.  If I get a chance, I'll see what I can find.

cheers,

Vadim

Thursday, January 2, 2014 1:16:41 PM
Sydney

re: Nintex Forms - Querying User Profiles

Thanks Vadim!

Sydney.

Tuesday, March 4, 2014 12:34:34 PM
Joe

re: Nintex Forms - Querying User Profiles

Hi, 

Thanks for the post but it seems that this code is not working with new browsers IE9+ and chrome. I am recvieing the following error

Object doesn't support property or method 'selectSingleNode' Error

selectSingleNode is no longer supported, any idea?

Friday, March 7, 2014 5:03:24 AM
Louis

re: Nintex Forms - Querying User Profiles

Hi Vadim,

Please how is the user profile docs being populated

 

Kind Regards

Louis

Friday, March 7, 2014 5:03:52 AM
Louis

re: Nintex Forms - Querying User Profiles

Hi Vadim,

Please how is the user profile docs being populated

 

Kind Regards

Louis

Tuesday, April 1, 2014 11:23:16 AM
Avinassh Reddy
Gravatar

re: Nintex Forms - Querying User Profiles

Hi Vadim,

 

 It works for full name but not for other fields. How do I debug ?

Tuesday, April 1, 2014 11:58:16 AM

re: Nintex Forms - Querying User Profiles

Hi Avinassh,

since it's JavaScript, I think there are developer tools in IE that you can install.  (it's been a while since I've used those).

What I usually do, is just use JavaScript alerts to pop up some variables so I can see what things look like.

cheers,

Vadim

Thursday, May 8, 2014 8:54:41 AM
Farooque Azam
Gravatar

re: Nintex Forms - Querying User Profiles

I m getting error like this. when I m going to implement your code

 

POST http://mysite-sp/_vti_bin/UserProfileService.asmx  500 (Internal Server Error) SPAPI_Core.js:52
Uncaught TypeError: Cannot read property 'NintexFormsPath' of undefined

Pls help me to resolve this as soon as possible

Thursday, May 8, 2014 8:11:11 PM
Rajesh
Gravatar

re: Nintex Forms - Querying User Profiles

Hei,

We are getting this error randomly and the workflow errors out. The user for whom this error is generated has an active user profile in SharePoint which we verified. Can you help?

"Error querying user profile. User Not Found: Could not load profile data from the database."

Do i need to configure "Advanced Settings" with username and passdown . I tryeind with Service account buhelpless :(

 

Thanks

Rahesg

 

Wednesday, May 28, 2014 1:26:44 PM
Aani
Gravatar

re: Nintex Forms - Querying User Profiles

We have nintex form and workflow trial version. Your code works in preview mode but does not work after publishing the form. Is there a way to figure out why is it not working after publishing the form?

 

Thanks,

Aani

Wednesday, May 28, 2014 1:41:46 PM

re: Nintex Forms - Querying User Profiles

HI Aani,

what are you trying to do?  Querying UserProfiles is now part of the NF product, so it might be easier to do that that use this library.

IF you could give me a brief description of what you're trying to do, I can let you know if it's possible.

cheers,

Vadim

Wednesday, May 28, 2014 2:33:44 PM
Aani
Gravatar

re: Nintex Forms - Querying User Profiles

Hi Vadim,

Thank you for quick response. I have a simple nintex form and i used above technique to auto populate current logged on user's  Full Name, Work Phone and Manager information (quering against UPS). I put the downloaded javascript libraries in style library instead of layouts folder and referenced in form settings. I used the same custom script that you provided. when i preview the form in design mode, those fields get auto populated (like i can see my full name, phone number and my manager userid) but if i publish the form and try to create a list item, those fields are empty. Is there a way to figure out why these fields are not getting any value after publishing the form? I am not sure if this is clear enough. FYI, I have nintex form trial version.

Thanks,

Aani

Wednesday, June 25, 2014 6:15:56 PM
Jun
Gravatar

People Picker

Hi Vadim,

Sorry to post an possibly irrelevant question under this article. I'm struggling to get help for my problem.

I have a people picker field on my form, only one person is allowed to be entered in this field. I would like to get the value of the people picker control when it loses focus.

After getting this value, I have a list with book titles and authors. I need to retrieve the book titles which has the authors of the people picker value. Then display those book titles in a dropdown list.

Hopefully I haven't confused you. I'm not trying to get the dropdown list populated yet as I'm stuck on getting the first bit done - getting the value from the people picker field.

Do you have any idea how this can be done?

Thanks very much.

Jun

Thursday, June 26, 2014 7:39:18 AM

re: Nintex Forms - Querying User Profiles

Hi Jun,

try adding a Calculated Value control to the form and configure the formula to just be the People Picker.

Run the form.  Does the Calculated Value control show what you selected in the people picker?

cheers,

Vadim

Monday, July 21, 2014 12:29:11 PM
Andy
Gravatar

re: Nintex Forms - Querying User Profiles

Hi Vadim, 

You said, "Querying UserProfiles is now part of the NF product,".  Can you point me in the direction of any kind of information on this?  I may be on an outdated version of NF, but if I can use it instead of this JS solution, that would be wonderful. 

Thanks! 

Andy

Monday, July 21, 2014 2:53:01 PM

re: Nintex Forms - Querying User Profiles

Hi Andy,

I guess it depends on what you are trying to do.  There is an inline function called userProfileLookup that may help you.

If you don't have the latest build, I'd recommend you upgrade.

cheers,

Vadim

Tuesday, July 22, 2014 8:53:01 AM
Andy
Gravatar

re: Nintex Forms - Querying User Profiles

Hi. Thanks for this!  

Is there a simple way to modify the JS to, instead of pulling the "Current User", instead pull from a people picker field?  For instance, if I want to pull all of this information for another user, by typing their name into a people picker field. Is that possible with modifying this solution? 

Thanks! 

Wednesday, August 6, 2014 4:44:03 PM
Dee
Gravatar

re: Nintex Forms - Querying User Profiles

Hi Vadim,

Am I right in assuming this only works for on prem? I think there might be a look back issue that you cant resolve in office365 that stops this from working, is that correct?

Monday, August 25, 2014 1:51:39 PM
denis
Gravatar

re: Nintex Forms - Querying User Profiles

Hello Mr. Vadim,

I would just fill out a field of type people and group with Current User SharePoint 2013.

the field is "requestor".
My Nintex Forms is the 2013 version.

is there any way to do this? Mr. could help me?

Thank you!

Monday, August 25, 2014 1:55:27 PM

re: Nintex Forms - Querying User Profiles

Hi Dennis,

so once you select a user from a People field, you want it to pull out information from your User Profile?

cheers,

Vadim

Tuesday, August 26, 2014 2:39:34 PM
denis
Gravatar

re: Nintex Forms - Querying User Profiles

Hello Mr. Vadim,

Thank you for your feedback!

What I need is a very simple thing, I want to populate the field People automatically with the login of the current user logged in SharePoint2013, I would like this to work in the new form.

cheers,

Denis

Thursday, August 28, 2014 1:25:12 PM
denis
Gravatar

re: Nintex Forms - Querying User Profiles

Hello Mr. Vadim,

sorry to insist, but I am in great need of your help.
do you have any news about my request?

Thank you !!

cheers,

Denis

Thursday, August 28, 2014 4:10:58 PM

re: Nintex Forms - Querying User Profiles

Hi denis,

open the setting of the People control.  Change the Default value source to "Specify default value".

Then in the Default Value, click on the little book icon and insert the Current User property.

Hope this helps.

FYI - for questions like this, if you want a faster response, you can reach out to support@nintex.com and the Nintex Support team would be able to help you out with support issues.

cheers,

Vadim

Friday, August 29, 2014 7:57:02 AM
denis
Gravatar

re: Nintex Forms - Querying User Profiles

Hello Mr. Vadim,

thanks for your help, helped me yes.
Thanks for the tip and the contact of Nintex.

cheers,

Denis

Tuesday, September 2, 2014 7:19:45 PM
Pramod
Gravatar

re: Nintex Forms - Querying User Profiles

Hi Vadim,

Thanks for your script and solution above. It got me working. Since I was using SharePoint 2013 and Nintex Forms 2013, got the below script which simplifies Query User Profile for user Information

NWF$(function(){ var mysiterequest = NWF$.ajax({
url: "/_api/SP.UserProfiles.PeopleManager/GetMyProperties",
method: "GET",
headers: {
"accept": "application/json; odata=verbose"
}
});
mysiterequest.then(
function(data){
NWF$('#' + varDisplayName).val(data.d.DisplayName);
NWF$('#' + varPosition).val(GetUserProperty(data,"SPS-JobTitle"));
NWF$('#' + varEmail).val(data.d.Email);
});
function GetUserProperty(data,propertyName){
var objects = data.d.UserProfileProperties.results.filter(function (e1) { return e1.Key == propertyName;});
if (objects.length > 0){
return objects[0].Value;
}
else{
return '';
}
}
});

I am extracting the Display Name, Email and Job Title of the current logged in user.

To get the list of properties and values, enter

<SharePoint Portal URL>/_api/SP.UserProfiles.PeopleManager/GetMyProperties 

in the web browser and this will retrieve the user information. Copy it to Visual Studio and the structured xml is readable.

Get the Key and pass it to propertyName parameter.

This wouldn't need any of the JavaScript Includes in form settings.

Hope this helps

Cheers

Friday, September 5, 2014 11:31:37 PM

re: Nintex Forms - Querying User Profiles

Hi Pramod,

that's awesome.  Thanks so much for sharing that script.  That'll make it so much easier for people to get the data they need from the User Profile.

cheers,

Vadim

Saturday, September 6, 2014 6:53:59 AM
Vladimir
Gravatar

re: Nintex Forms - Querying User Profiles

Hi Vadim. How implement you code  in sharepoint 365?

 

https://xxxxxxx.sharepoint.com/sites/site/_api/contextinfo. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://formso365.nintex.com' is therefore not allowed access. FormsPart.aspx?SPAppWebUrl=https://terralinktechnologies-db13ad7592ccbc.sharepoint.com/sites/conden…

Saturday, September 6, 2014 9:20:16 AM

re: Nintex Forms - Querying User Profiles

Hi Vladimir,

I haven't tried this on O365.  But a few people now have told me that this doesn't work in O365.  I don't have a workaround that I have found for this.

cheers,

Vadim

Monday, September 15, 2014 2:49:17 AM
Ryan
Gravatar

re: Nintex Forms - Querying User Profiles

Hi,

I'm trying to implement this with the added functionality of a people picker field and a Refresh button, so that if the user is submitting a form on behalf of another user they can select the user and hit refresh to run the functions again. I seem to be having issues with the format of the username that is passed to the SPAPI service. Any idea what this should look like? Currently the value we're getting from the people picker has some ADFS "bits", the domain and then the username. We've tried hardcoding the username in, but can't seem to pass a valid value and keep getting a null back.

Thanks

Monday, December 1, 2014 9:34:38 AM
Pat
Gravatar

re: Nintex Forms - Querying User Profiles

Hi,

Do you have an idea how to get the displayName of the manager? It looks like domain\login...

Thanks

Wednesday, March 18, 2015 5:57:23 AM
Muhammad Maher
Gravatar

re: Nintex Forms - Querying User Profiles

Hi vadim,

Thanks a lot for your useful topics, i really appreciate your effort.

I used your code as u have mentioned exactly but when i query the ID nothing happens 

I'm pretty sure that i missed something in this function 

var lists = new SPAPI_Lists('')
var userprofiles= new SPAPI_UserProfile('')
var currentUser = userprofiles.getUserProfileByName('');

 

i used this as is, i didn't pass any parameters to these functions and i don't know what exactly should i pass, could u tell me an example

 

Note that i added the SPAPI Library file to a sharepoint doc library and i attached them as u mentioned. 

Wednesday, March 18, 2015 8:17:46 AM

re: Nintex Forms - Querying User Profiles

Hi Muhammad,

check the currentUser.status. Is it set to 200?

cheers,

Vadim

Monday, May 4, 2015 4:00:14 AM
HARY
Gravatar

re: Nintex Forms - Querying User Profiles

SPAPI_Lists is undefined

Monday, May 4, 2015 6:05:52 AM

re: Nintex Forms - Querying User Profiles

Make sure you have the SPAPI JS files included in your form.

cheers,

Vadim

Thursday, May 7, 2015 2:28:44 AM
Hary
Gravatar

re: Nintex Forms - Querying User Profiles

Thanks Vadim. now that i have ensured that SPAPI js files are added. Now i am getting first name & last name undefined.

This is the code which i am trying as i need only full name.

NWF$(function () {
 var lists = new SPAPI_Lists(list_url)
 var userprofiles= new SPAPI_UserProfile(url)
 var currentUser = userprofiles.getUserProfileByName(null);
 if(currentUser.status == 200)
 {
 return currentUser;
 }
 else
 {
 return null;
 }
 

 function getPropertyValue(userProfileDoc,propertyName)
 {
 try
 {
 var node = userProfileDoc.responseXML.documentElement.selectSingleNode('//PropertyData/Name[.="' + propertyName+ '"]');
 return node.parentNode.selectSingleNode('Values/ValueData').text;
 }
 catch(e)
 {
 return '';
 }
 }
 function getFullName(userProfileDoc)
 {
 var firstName = getPropertyValue(userProfileDoc,'FirstName');
 var lastName = getPropertyValue(userProfileDoc,'LastName'); return firstName + ' ' + lastName;
 }
 // Get User Info
 var userProfile = getUserProfileInfo();
 var userName = getFullName(userProfile);
 NWF$('#' + varNameID).val(userName);
});

Saturday, May 9, 2015 12:16:04 AM

re: Nintex Forms - Querying User Profiles

Hi Hary,

you'll need to start debugging the XML to see why you are getting that.  Obviously, the XML is missing the FirstName.  Maybe it has a different name or spelled differently.

cheers,

Vadim

Monday, July 20, 2015 2:15:05 PM
Renee
Gravatar

re: Nintex Forms - Querying User Profiles

Hi Vadim, 

Is it normal to have the form lock due to the Java variable? When I set the variable in the form, even the preview of the form will not load (please wait... FOREVER or at least up to 3 hours) but if I pull the java variable out, the form loads, I just don't get any value.  Is there a way to get around it? I have tried on different PC's and it is still locking. 

Thank you!
Renee

Monday, July 20, 2015 3:21:49 PM

re: Nintex Forms - Querying User Profiles

Hi Renee,

that sounds like there is something in the JavaScript that is breaking the rest of the JavaScript.  Usually that means a semi-colon is missing where it's needed, or there's an open bracket without a closed one.

JavaScript isn't very forgiving.

cheers,

Vadim

Friday, September 11, 2015 3:33:37 AM
Andy
Gravatar

re: Nintex Forms - Querying User Profiles

Hi Vadim

 

Thank you for your great post which works under IE9. In IE 11 however I cannot see more the AD-Information in the controls.

I use Nintex Form 2013 (2.4.1.0). In IE 11 Javascript is enabled.

 

Do you have an idea why it does not work under IE 11.

 

Cheers,

 

Andy

Friday, September 11, 2015 5:39:40 AM
Andy
Gravatar

re: Nintex Forms - Querying User Profiles

In IE11 in the developer mode (F12) I can see the user profile values in the document mode for IE9 but not more under the document mode for IE10 or Edge. Here (http://stackoverflow.com/questions/10975107/forcing-internet-explorer-9-to-use-standards-document-mode) I find a solution how to change it in a site with

 <!doctype html> <meta http-equiv="X-UA-Compatible" content="IE=9">

 

But where do I have to set it?

 

Cheers

 

Andy

 

Thursday, January 14, 2016 6:26:47 AM

re: Nintex Forms - Querying User Profiles

In IE11, the method selectSingleNode() is no longer supported. We can instead use the getElementsByTagName()


Here is a modified version of the getPropertyValue() function used in the article that will work in IE11.

 

function getPropertyValue(userProfileDoc, propertyName) {

  try {

   var propNodes = userProfile.responseXML.documentElement.getElementsByTagName('PropertyData');

   for(var i = 0; i < propNodes.length; i++)

   {

     node = propNodes[i];

     var name = node.getElementsByTagName('Name')[0].textContent;

     if (name==propertyName) {

        return node.getElementsByTagName('ValueData')[0].textContent;

     }

   }

  } catch (e) {

   return '';

  }

}

 

Regards,
Jean-Pierre

Thursday, February 11, 2016 11:52:25 AM
Eric Halsey
Gravatar

re: Nintex Forms - Querying User Profiles

Hi Vadim,
I don't see the userProfileLookup in my list of Inline Functions in Nintex Forms 2010 ( 1.11.0.0 ) .

You must sign in to this site to post comments.
Already Registered?
Sign In
Not Yet Registered?
Register

Statistics

  • Entries (293)
  • Comments (1778)

Categories