Value does not fall within the expected range


Time introduced some strange problem.

I needed to build a list with a lookup field.
So build fields.. Then create content type.. and than a list detention....
Just.. Piece of cake.
As you know, Lookup field problem must be linked to an existing list.

So checking founder of the source list and then create the field.

Something that looks like the following code plus or minus

<Field Type="LookupMulti" DisplayName="Your List" Required="FALSE" EnforceUniqueValues="FALSE" Direction="None" List="Lists/YourList"      ShowField="Title" Mult="TRUE" Sortable="FALSE" UnlimitedLengthInDocumentLibrary="FALSE" Group="YourGroup" ID="{448f00a7-6cb5-4340-985f-990dd354f135}" SourceID="{1ce2cabb-bea1-4137-aee8-b4f12b17abcc}"      StaticName="YourName" Name="YourName" Version="3" />



The code worked fine until .... I had to create a new site with the list above ..

I got the following error



System.ArgumentException: Value does not fall within the expected range. at Microsoft.SharePoint.Library.SPRequestInternalClass.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd) at Microsoft.SharePoint.Library.SPRequest.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd) at Microsoft.SharePoint.SPFieldCollection.AddFieldAsXmlInternal(String schemaXml, Boolean addToDefaultView, SPAddFieldOptions op, Boolean isMigration, Boolean fResetCTCol) at Microsoft.SharePoint.SPContentType.ProvisionFieldOnList(SPField field, Boolean bRecurAllowed) at Microsoft.SharePoint.SPContentType.ProvisionFieldsOnList() at Microsoft.SharePoint.SPContentType.DeriveContentType(SPContentTypeCollection cts, SPContentType& ctNew) at Microsoft.SharePoint.SPContentTypeCollection.AddContentTypeToList(SPContentType contentType) at Microsoft.SharePoint.SPContentTypeCollection.AddContentType(SPContentType contentType, Boolean updateResourceFileProperty, Boolean checkName, Boolean setNextChildByte) at Microsoft.SharePoint.SPContentTypeCollection.Add(SPContentType contentType) at Microsoft.SharePoint.ApplicationPages.AddContentTypeToListPage.Update(Object o, EventArgs e) at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


When I tried to build manually the column with the field ... I got something similar



System.ArgumentException: Value does not fall within the expected range. at Microsoft.SharePoint.Library.SPRequestInternalClass.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd) at Microsoft.SharePoint.Library.SPRequest.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd) at Microsoft.SharePoint.SPFieldCollection.AddFieldAsXmlInternal(String schemaXml, Boolean addToDefaultView, SPAddFieldOptions op, Boolean isMigration, Boolean fResetCTCol) at Microsoft.SharePoint.SPList.ProvisionField(SPField fld, SPAddFieldOptions op, Boolean bRecurAllowed, Boolean bAddToDefaultView, Dictionary`2 dictAdd) at Microsoft.SharePoint.ApplicationPages.AddFieldFromTemplatePage.ProvisionFieldOnListCore(SPField fld, Boolean bRecurAllowed, Boolean bAddToDefaultView, Dictionary`2 dictAdd) at Microsoft.SharePoint.ApplicationPages.AddFieldFromTemplatePage.Update(Object o, EventArgs e) at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)




I tried Google's solutions, build console accesses picks up and changes the field from
List="Lists/YourList"
To
List="35ae7ed3-b23f-4f71-a2a3-8ad482ad9ab6"

The list has been changed from path to guid

But interested permissions list kept me fix it

The solution was simpler - I changed the feature in packge and installed again. I've iisreset (that's xml update feature to reset IIS binding)

Now the field looks like this

<Field Type="LookupMulti" DisplayName="Your List" Required="FALSE" EnforceUniqueValues="FALSE" Direction="None" List="35ae7ed3-b23f-4f71-a2a3-8ad482ad9ab6"      ShowField="Title" Mult="TRUE" Sortable="FALSE" UnlimitedLengthInDocumentLibrary="FALSE" Group="YourGroup" ID="{448f00a7-6cb5-4340-985f-990dd354f135}" SourceID="{1ce2cabb-bea1-4137-aee8-b4f12b17abcc}"      StaticName="YourName" Name="YourName" Version="3" />

Good day,
Roi



Comments

Popular posts from this blog

A sharepoint list view of the current month

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters

Export SharePoint 2010 List to Excel with PowerShell