How to set default value for lookup column in Nintex forms for Office 365 SharePoint online?

nintex forms tutorial

In this post, we will discuss how we can 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 which has two columns and I am displaying the values in another SharePoint list form. If you are new to Nintex forms, check out Working with Nintex Forms for Office 365 SharePoint Online.


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.

nintex forms set lookup field value
nintex forms set lookup field value

Now if you will look at the preview you can see all the fields are coming like below:

nintex forms set lookup field value
nintex forms set lookup field value

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)

set default value in lookup column nintex forms
set default value in lookup column nintex forms

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.

nintex forms list lookup default value
nintex forms list lookup default value

Then Save the form as it will appear like below:

nintex forms set lookup field value
nintex forms set lookup field value

You may like following Nintex forms for Office 365 tutorials:



Hope this Nintex Forms for Office 365 tutorial will be helpful to you to set a default value in lookup column Nintex forms for Office 365 SharePoint Online.

Check out Best Alternative to InfoPath -> Try Now

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →