In this Nintex forms tutorial, let us discuss a Nintex forms lookup function example. Also, we will see, how to set a default value to a SharePoint lookup column using Nintex forms for Office 365.
Nintex forms lookup function
When you need to pull the data to your Nintex forms from other SharePoint lists, we can use the Lookup runtime function.
Lookup function which allows you to retrieve data from a column within a SharePoint list and display that data on a form or use it in a Formula in Nintex Form.
The Lookup function can be utilized within a Calculated Value control, Form Variable, or Rule.
The syntax for configuring the Lookup function in Nintex Form:
lookup(List Title, Column to filter on, Value to filter on, Output column)
- List Title – The title of the list that contains the data you are retrieving.
- Column to filter on – The name of the column in the list that you want to filter on. This column is used to filter which list items are returned as matches occur against the third parameter.
- Value to filter on – The specified value that is compared against each item in the list. Here, be sure to use a Named Control instead of an item in the Item Properties tab for this value.
- Output column – The column name in the list from which the data is retrieved.
In our example, I have an employee list in SharePoint Online which has a department number column.
When a user enters a value into the Department Number field, the Employee form pulls back data from the Department list using the Lookup function in Nintex form. The following two lists were created and configured for this example.
Step 1: We created a list called “Employee Info” in SharePoint Online.
Step 2: Second List called “Department” and it has columns like: Department No, DeptName and Location like below:
Step 3: Open the Employee Info form in the Nintex Forms designer. Add a ” Calculated Value ” column to the Nintex form to display the Department Name(DeptName) and for Location also as shown below.
- For DeptName control, double-click on “Calculated Value ” control.
- To configure the Control Settings with the following values: Formula = lookup(“Department”, “Department No”, DepartmentNO, “DeptName”) where “DepartmentNO” is the Name of the form control.
- Name = DepartmentName
- Connected to = DeptName
- Save as data type = String
- Recalculate formula on view mode = Yes
Step 4: For the Location control, do the same thing as shown below.
Formula = lookup(“Department”, “Department No”, DepartmentNO, “Location”).
- Name = Location
- Connected to = Location
- Save as data type = String
- Recalculate formula on view mode = Yes
Step 5: Save and Publish the Nintex form(Employee Info), Enter a valid value into the Department No field on the form and go to another field. The form will automatically pull and display the data from the Department list into the Department Name(DeptName), and Location fields as shown below.
This is how to use the Nintex forms lookup function in SharePoint online.
Read: Nintex workflow examples
Set default value for lookup column in Nintex forms
Let us see, how to set a default value for lookup columns in Nintex forms for Office 365 SharePoint online.
Here in this particular example, I have a SharePoint Online list that has two columns and I am displaying the values in another SharePoint list form.
Open the SharePoint Online list where you want to add the lookup columns. From the ribbon, click on Nintex forms which will open the Nintex forms designer.
Now if you will look at the preview you can see all the fields are coming like below:
But here my requirement is to set a default value for it. After Google, I got the easiest solution from here.
We can achieve this thing by writing a few lines of JavaScript code.
First, double-click on the control and then expand the Advanced tab and there select Yes for “Store Client ID in JavaScript variable”. And then give a variable name like below: (Here I have given ddlstateID)
Then from the Ribbon (Designer Tab), click on Form Settings. Then expand the Custom JavaScript tab and put the below code.
NWF.FormFiller.Events.RegisterAfterReady(function () {
NWF$('#' + ddlstateID).on('change', function (e) {
if (e.originalEvent == undefined) {
if (this.value == "") {
this.value = "3";
}
}
});
});
Here we need to see this.value = “3”; Here 3 is the item id in the source list which I want to set the default value.
Then Save the form as it will appear like below:
This is how to set a default value in lookup column Nintex forms for Office 365 SharePoint Online.
You may like:
- Cascading dropdown in Nintex Forms + Responsive Forms
- Nintex form rules + validation examples
- How to Customize SharePoint Modern list form using JSON
In this tutorial, we learned about the nintex forms lookup function example and how to set a default value to a lookup column in the SharePoint list using Nintex forms.
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.