Sunday, April 26, 2015

How to get any user profile property value on a Nintex Form 2010 in seconds

This can be a very helpful and handy feature for getting user profile property values for logged in user on a Nintex Form for example if there is a requirement to auto populate user phone number in a field when the New form loads, or adding First Name and Last Name to a Name field automatically on load or populating user's department in a field.

To achieve this we can use the inbuilt function provided by Nintex. Here is how:

1. Drag a Calculated value on the form and double click on the control to configure.
2. Go to the Formula field and click on the function button.

 

3. Go to Runtime functions tab and select userProfileLookup function. First argument in this function is the user ID of the user. I have taken current user variable which contains existing user login id. Second argument is the property name "WorkPhone" Use it as shown below in the screenshot



and here is the output of this

A complete set of user profile properties can be found at MSDN. Sometimes we are in need of just one property and do not want to use lot of code to bring that value to the form. So this is a precise and cleaner way of getting those properties handy.

However, it should not be over used because every call made by this method hits the user profile service to get the requested value. I will suggest to keep these calls to minimum on your form to avoid performance bottlenecks.

Happy coding.

No comments: