SharePoint 2010 – InfoPath 2010 – Lookup Field Error

While using InfoPath Form for a SharePoint 2010 List > I encountered the following error.

InfoPath cannot submit the form because it contains errors.

image

Cannot be blank.

Failed Solutions

I tried with the following approaches & Failed:

  1. Manually created the field from InfoPath & Assigned Validation Rule.  Failed as Validation rule was not enabled for the field
  2. Removed mandatory check box for the field.  Worked but customer requires the field to be mandatory. Failed.

image

Following are the 2 lists included:

  1. Contracts list with Customer Name field & Product Code field pointing to Products list
  2. Products list with Code field

Concrete Solution

  1. The following approach worked:
  2. Removed the field from SharePoint
  3. Created the field from InfoPath
  4. Used Choice field with multiple values
  5. Used Data Connections to Populate field value
  6. Published & Tested
  7. It worked

Steps

Following are the steps to implement the Solution.

Step 1: Delete existing field

Delete  the field from SharePoint.  Save Changes.

Delete the field-row from InfoPath Form.  Save Changes.

image

Step 2: Add Field from InfoPath

Create the field from InfoPath. 

image

Choose Actions > Add Field

Choose Data type > Choice (allow multiple selections)

Choose Mandatory option

Click OK button to save changes.

Step 3: Add Field to Form

Right click and add a row to InfoPath form.

image

Drag & Drop the new field Product Code from the fields list to the form.

image

Step 4: Add Data Connection

Now the new field & control is missing data-population.

To add a data connection > right click the product code input-area & choose Properties menu.

image

In the appearing Properties box > Choose Get choices from external data sources option.

image

Click on the Add button to create the data source.

Choose the options as shown below.

image

image

Choose your SharePoint site as shown below.

image

Choose the Lookup List.  (the secondary list from where data is pulled)

image 

Choose the fields to display.  (In our case only Code field exists)

image

Enter the name for the data connection.  (You may use the Suffix as DS)

image

Click the Finish button to save changes.

image 

Step 5: Save & Publish

Click the Save button & Publish the form

image

Step 6: Test the form

Test the form by adding a new item.  You should see the item insertion succeeded without any errors.

image

You can try with multiple-value checking & getting displayed in the view mode too.

image

This concludes our solution to Lookup field error in InfoPath forms.  I hope you enjoyed  the solution. :)

Leave a Reply

Your email address will not be published. Required fields are marked *