Recent

Nintex Forms default value for lookup fields

Since Lookup fields grab choices from a different list, you can’t specify the default value like you can for a regular dropdown. Instead you need to add a little javascript to specify what choice you want to be the default value in the dropdown.

By default all the choices in the a Lookup dropdown will be sorted alphabetical, with no default value specified, just the text ‘Please select a value…’ being displayed:
Dropdown-default-value-14-6

Setting Nintex Forms lookup default value

(updated 5/8/2016): Nintex updated the lookup control which required a change in the custom javascript used.  New solution was copied from Stephen Saw’s reply:
https://community.nintex.com/thread/7662

1. The first thing you need to do is decide what you want the default value to be, and find the ID number for that selection. To do this go to the list that the lookup dropdown is going to be pointed at. Then edit or create a view adding the ‘ID’ field to the view. Now you can easily see the ID number for each of the items in that list. In this example I want ‘TEst 1’ to be default value so the ID for that selection is 1.
Dropdown-default-value-14-7

2. Now that you know the ID of your default value, go to your Nintex form, click on the ‘Nintex Forms’ tab, click on ‘Settings’, expand ‘Custom JavaScript, and paste in the following:
NWF.FormFiller.Events.RegisterAfterReady(function () {
NWF$(‘#’ + ddllookupID).on(‘change’, function (e) {
if (e.originalEvent == undefined) {
if (this.value == “”) {
this.value = “1”;
}
}
});
});
Note: Change the 1 above to the ID of the default item you want.

Click the Save button to save your form settings.
Updated-lookup-default-value-16-1

3. Then double click on your dropdown lookup field to bring up that fields Control Settings. Click on ‘Advanced’, select ‘Yes’ for Store Client ID in Javascript variable, type in ddllookupID into the Client ID javascript variable name field:
Dropdown-default-value-14-4Click the Save button to save your conrol settings.

4. Now that everything is setup, preview your form to make sure it works. Click on the ‘Nintex Forms’ tab, click on the ‘Preview’ option, choose ‘New’ mode, click on ‘Generate preview’, and you should now see your lookup dropdown field displaying a default value:
Dropdown-default-value-14-5

About Nick Hurst (84 Articles)
SharePoint and Nintex developer who strives to find easy to deploy and maintain solutions for business problems.

6 Comments on Nintex Forms default value for lookup fields

  1. Joakim Westlund // April 25, 2016 at 1:40 pm // Reply

    Hello. I can’t get this to work. I am sure I have done exactly the way you described but nothing happens. I use Sharepoint 2013. Maybe the script needs to be fixed for this version?

    Best regards Joakim

    Like

  2. Leif Frederiksen // April 29, 2016 at 9:57 am // Reply

    Hi Nick,
    Great solution to this issue.

    I have the same challenge in the Nintex Mobile Apps – which unfortunately does not support Javascript.

    Any ideas on how to handle defaulting in that scenario?

    And what about defaulting to the value in the dropdown that the user selected the last time she used the form? In the browser scenario I use cookies to handle this, but what about in the mobile app?

    Regards Leif

    Like

  3. Hi, this seems to no longer work with the latest version of Nintex Forms 2013. Found an updated solution here. https://community.nintex.com/thread/8657.

    Like

    • Thanks for the heads up about the control changing Tony, you were right that the old way no longer works. In this example we aren’t getting the default value from another control like the solution presented in thread 8657. I updated the post above to a new method which does work for specifying a static default value for the lookup field. I found the solution at:
      https://community.nintex.com/thread/7662

      Thanks.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: