Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've got several list which have lookup fields, and I can't add new items to any of them. Every time I've clicked save, I get this error:

"Invalid data has been used to update the list item. The field you are trying to update may be read only."

None of the fields are set to read only. I've built the list "manually" by creating the XML files longhand in VS, but all those without lookup fields work fine. I've tried adding data manually by populating the element in the list instance, but I don't know how to properly do the lookup field.

Any ideas?

Edit: Relevant field XML

<Field ID="{5115854A-BC9E-498B-B54E-2EAAD6E89119}"
    Type="Lookup"
    Name="ParentCode"
    DisplayName="BL2"
    List="Lists/BL1"
    FieldRef="Code"
    ShowField="Title"
    Group="BL Columns">
</Field>

Which references these fields in list BL1:

<Field ID="{DAAEF78C-4756-458E-8F8F-B40352BF5BEA}"
    Type="Text"
    Name="Title"
    DisplayName="BL1"
    Group="BL Columns">
</Field>
<Field ID="{42C00D43-D33F-420A-A85A-15E5AD0183F8}"
    Type="Text"
    Name="Code"
    MaxLength="6"
    DisplayName="BL1 Code"
    Group="BL Columns">
</Field>

The contents of the lists are shown fine in the form dropdown, it's just the save that's broken.

share|improve this question
    
Can u post your code? Thanks –  Frederik P. Apr 26 '12 at 10:32

2 Answers 2

up vote 0 down vote accepted

You should use ID of the lookup target, when setting values to look up fields. Take a look at this post How to set ListItem Lookup Field value

share|improve this answer
    
Perfect. Thanks! –  Moray Apr 27 '12 at 7:36

I think you have to set a extra field property --> Overwrite="TRUE"

share|improve this answer
    
While this is true, it will not fix the error, but it will allow the fix to be added. –  thantos Dec 1 '12 at 14:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.