Wednesday, March 2, 2011

Creating Default Values for lookup fields in InfoPath 2010

Creating a default value for a lookup field in SharePoint/InfoPath 2010 is not intuitive. When you initially create the lookup, there is no place for default value (as there is for non lookup selections) and when you open the form in infopath, and right click the lookup field, there is no option there to display a default value either.

This solution selects the default value on the creation of a new form record. It does not update existing records with no value selected to the default value.

Here is how to set a default value for a lookup:

Open the form in infopath.
Click the "File" tab ->
Click the "Form options" button in the "Advanced Form Options" section ->
Select the "Advanced" category (see screenshot 1) ->
Click the button "Edit Default Values" ->
Click the "+" on "myFields" ->
Click the "+" on "dataFields" ->
Select the lookup field you wish to set a default value for by clicking on it (see screenshot 2)->
Enter in the default value for the lookup field. Remember that the default value here is the ID of the record, not the name. See screen shots below ->
Click "OK" then "OK" again and first test functionality using "preview" button in infopath ->
Verify your lookup is now populating with a default value ->
Publish the form.

Screenshot 1, Advanced Form Options from file tab

Screen shot 2, Setting ID of default value

No comments:

Post a Comment