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.

Tuesday, September 30, 2014

How to make attachment mandatory in Nintex Form in SharePoint 2010

Lot of times we have requirement to make attachments to a form mandatory in a SharePoint list form. This validation is not available out of the box, although can be achieved very easily by using JQuery. Here is how.
Define the following function in a custom JavaScript file i.e. Validate.js. Include the JQuery and custom validate.js file in Nintex form in the order shown in the below screenshot.


function ValidateForm()
{
//attachment check
if($('.nf-attachmentstable tr').length < 1){
alert("Please attach a file"); 
return false;
}
}


On the submit button set the following as client function:




Here is the result.

Hope this snippet is useful to apply attachment validation in Nintex Forms. Happy coding :)