Lookup Field in list definition <nativehr>0x80070057</nativehr>
-
Wednesday, February 10, 2010 8:05 PMI have created a content type with a lookup field. From this content type I have created a List Definition. The deployment and activation process works, but when I want to create a new item and save it I'll get an error:
"<nativehr>0x80070057</nativehr><nativestack></nativestack>Invalid data has been used to update the list item. The field you are trying to update may be read only."
Stack trace:
[ArgumentException: <nativehr>0x80070057</nativehr><nativestack></nativestack>Invalid data has been used to update the list item. The field you are trying to update may be read only.]
My markup for the lookup field:
Microsoft.SharePoint.Library.SPRequestInternalClass.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback) +0
Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback) +406
Microsoft.SharePoint.SPListItem.AddOrUpdateItem(Boolean bAdd, Boolean bSystem, Boolean bPreserveItemVersion, Boolean bNoVersion, Boolean bMigration, Boolean bPublish, Boolean bCheckOut, Boolean bCheckin, Guid newGuidOnAdd, Int32& ulID, Object& objAttachmentNames, Object& objAttachmentContents, Boolean suppressAfterEvents, String filename) +3368
Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents, String filename) +469
Microsoft.SharePoint.SPListItem.Update() +161
Microsoft.SharePoint.WebControls.SaveButton.SaveItem(SPContext itemContext, Boolean uploadMode, String checkInComment) +807
Microsoft.SharePoint.WebControls.SaveButton.OnBubbleEvent(Object source, EventArgs e) +1151
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +70
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
<Field ID="{15bfea73-0695-4b1d-8064-a97199a92431}" Name="CustomerLookup" Group="Project Group" Type="Lookup" DisplayName="Customer" Required="FALSE" EnforceUniqueValues="FALSE" List="Lists/Customers" ShowField="Company" UnlimitedLengthInDocumentLibrary="FALSE" RelationshipDeleteBehavior="None" FieldRef="Company" StaticName="Customer"/>
Thanks in advanced.
EStruyf- Edited by EStruyf Wednesday, February 10, 2010 8:06 PM Added lookup markup
All Replies
-
Thursday, February 11, 2010 2:31 AMIn 2007 I think this was caused by the security digest missing. We got around it by using SPWeb.AllowUnsafeUpdates = true. Did you try that?
- Edited by Brian Bedard Thursday, February 11, 2010 9:14 PM typo
-
Thursday, February 11, 2010 8:23 AMI haven't tried this.
In 2007 this approach worked for me, so that's the weird part.
EStruyf -
Monday, July 05, 2010 7:25 AM
Hi,
I am developing in Sharepoint 2010 RC and also facing this issue. Created custom list definition in VS 2010 and added two lookup columns in the list definition in elements.xml and schema.xml files. These columns are provsioned perfectly fine in Sharepoint but when I try to add items to this list then I am getting the above mentioned error.
What is the solution to the above issue? Here is the field xml of my lookup columns
<Field Type="Lookup" DisplayName="Category ID" Required="FALSE" Sortable="FALSE" ReadOnly="FALSE" List="Lists/ScoreCategoryMasterList" ID="{E9107F5C-0F27-4A86-A245-FA875AE24A39}" FieldRef ="ID" ShowField ="ID" StaticName="CategoryID" Name="CategoryID" Group="Custom Columns" UnlimitedLengthInDocumentLibrary="FALSE" EnforceUniqueValues ="FALSE" EnableLookup="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v4" PrependId="TRUE" /><
Field Type="Lookup" DisplayName="Video ID" Required="FALSE" Sortable="FALSE" ReadOnly ="FALSE" List="Lists/VideosList" FieldRef="ID" ID="{1395DC17-AE78-4E49-BFC2-A247B3A82DF1}" ShowField ="ID" StaticName="VideoID" Name="VideoID" Group="Custom Columns" UnlimitedLengthInDocumentLibrary="FALSE" EnforceUniqueValues ="FALSE" EnableLookup="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v4" PrependId="TRUE" />
-
Monday, July 05, 2010 7:29 AMYou can't set the list reference in the way you do it. You HAVE TO use the guid of the list to create your lookup field.
-
Monday, July 05, 2010 8:24 AM
According to Josh Gaffey's Blog we can refer list name in the declaration which is supposed to be a new feature in Sharepoint 2010. This means that we cannot use this new property in provisioning lookup fields.
http://blogs.msdn.com/b/joshuag/archive/2008/03/14/add-sharepoint-lookup-column-declaratively-through-caml-xml.aspx
I will try using the GUID. Lets see. -
Monday, July 05, 2010 9:36 AMI've read a bunch of blogs and articels saying that it should be possible, but I was never able to create a working solution. If you find a solution, please provide your code here.
-
Sunday, March 20, 2011 7:26 PM
I was able to get it working by removing the FieldRef and StaticName columns:
<
Field ID="{85F7F07E-C6D7-475D-867F-74656984D6B1}" Name="NewPosition" Type="Lookup" DisplayName="New Position" List="Lists/Positions" ShowField="Title" Required="FALSE"
/>
- Marked As Answer by EStruyf Wednesday, March 23, 2011 3:59 PM
-
Wednesday, March 23, 2011 3:48 PM
Cool, I'll try it when I have the time.
Thanks.
*Edit* Did a quick test an it works. Thanks again.
http://estruyf.be/blog -
Tuesday, April 05, 2011 9:01 AM
By only removing FieldRef property, it will work
~Mehul Shah- Proposed As Answer by Shah Mehul Tuesday, April 05, 2011 9:02 AM
-
Sunday, March 25, 2012 8:48 PM
I found that I required the FieldRef and StaticName attributes. Specifying the following attribute solved this issue for me:
Overwrite="TRUE"
Use TRUE instead of true.
- Edited by Chad Mellor Sunday, March 25, 2012 8:49 PM
- Proposed As Answer by Filipe [CMPS] Cavalcante Friday, June 15, 2012 3:15 PM
-
Friday, June 15, 2012 3:15 PM
I found that I required the FieldRef and StaticName attributes. Specifying the following attribute solved this issue for me:
Overwrite="TRUE"
Use TRUE instead of true.
This works for me!

