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

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.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>