Tags

,

If you are using MOSS 2007 and you see “Value is not among the set of valid lookup values” error when you save a form, this is caused by a look-up field. Unfortunately, being an old system, SharePoint 2007 doesn’t render this type of field as a select HTML element. Instead it appears to be a textbox HTML element with some associated JavaScript events handlers. This means, an user can actually write down a value which doesn’t exist in the look-up list.

MOSS2007-lookup-error

Now as you know where is the problem, you can restrict the user’s input by changing SharePoint:FormField control associated for the column with a SharePoint:DVDropDownList displaying values provided by a SharePoint:SPDataSource. So instead of having a code like this:

<SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="New" FieldName="InternalFieldName" __designer:bind="{ddwrt:DataBind('i',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@InternalFieldName')}"/>

you can a new code:

<SharePoint:DVDropDownList runat="server" id="ff1{$Pos}" DataSourceID="SPDataSourceId" DataValueField="ID" DataTextField="Title" __designer:bind="{ddwrt:DataBind('i',concat('ff1',$Pos),''SelectedValue','SelectedIndexChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@InternalFieldName')}" />

Please note the followings:

  • Drop down control is getting the data from an SPDataSource and data value field is ID.
  • Data text field is set to Title, but can be any other column from look-up list you want to display.
  • __designer:bind attribute was changed and ‘Value’ parameter changed with ‘SelectedValue’ and ‘ValueChanged’ was changed with ‘SelectedIndexChanged’.

I hope this will help you fixing the issue. In case you are planing to upgrade from MOSS 2007, you should not be worry about it anymore, as this was fixed. I checked on SharePoint Online, SharePoint 2013 and 2010 version.

Advertisements