none
Lookup Field in list definition <nativehr>0x80070057</nativehr>

    Soru

  • I 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.]
    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
    My markup for the lookup field:
    <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
    • Düzenleyen EStruyf 10 Şubat 2010 Çarşamba 20:06 Added lookup markup
    10 Şubat 2010 Çarşamba 20:05

Yanıtlar

  • 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"

    />

    • Yanıt Olarak İşaretleyen EStruyf 23 Mart 2011 Çarşamba 15:59
    20 Mart 2011 Pazar 19:26

Tüm Yanıtlar

  • In 2007 I think this was caused by the security digest missing.  We got around it by using SPWeb.AllowUnsafeUpdates = true.  Did you try that?
    • Düzenleyen Brian Bedard 11 Şubat 2010 Perşembe 21:14 typo
    11 Şubat 2010 Perşembe 02:31
  • I haven't tried this.

    In 2007 this approach worked for me, so that's the weird part.

    EStruyf
    11 Şubat 2010 Perşembe 08:23
  • 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" />

    05 Temmuz 2010 Pazartesi 07:25
  • You 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.
    05 Temmuz 2010 Pazartesi 07:29
  • 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.

    05 Temmuz 2010 Pazartesi 08:24
  • I'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.
    05 Temmuz 2010 Pazartesi 09:36
  • 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"

    />

    • Yanıt Olarak İşaretleyen EStruyf 23 Mart 2011 Çarşamba 15:59
    20 Mart 2011 Pazar 19:26
  • 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
    23 Mart 2011 Çarşamba 15:48
  • By only removing  FieldRef  property, it will work
    ~Mehul Shah
    • Yanıt Olarak Öneren Shah Mehul 05 Nisan 2011 Salı 09:02
    05 Nisan 2011 Salı 09:01
  • 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.

    25 Mart 2012 Pazar 20:48
  • 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!

    15 Haziran 2012 Cuma 15:15