3

This is the code I used in Schema.xml

 <Field Name="employee" ID="{44678273-e07d-43de-8096-dc2ce3c105cf}"
    DisplayName="employee" Type="Lookup" List="Lists/Employee" 
    ShowField="Address" EnableLookup="TRUE"/>

Even if add one more column to the list using list definition after existed item will be lost.

  • Go to list settings and check if relationship is properly configured – Taran Goel Jan 3 '16 at 7:44
0

If I understand the question correctly you have created one list from a list definition, then created a lookup column to that list using a declarative/CAML approach. The resulting lookup column isn't begin populated with the items from the look up list.

If this is indeed your situation, for this approach to work there are two requirements:

  1. the lookup list should be available on the site before the lookup is created. This means that if the lookup list and the column are both created decoratively from the same feature, the lookup won't be connected correctly to the list (you can check this directly from SharePoint user interface - the column settings should show that the lookup is miss-configured).
  2. Historically, lookup were intended to point to the GUID of the lookup list - which would change when the list is deployed somewhere else. AFAIK, to be able to use the url like you do, you should specify the WebId parameter too.

Try to change your line to something like:

<Field Name="employee" ID="{44678273-e07d-43de-8096-dc2ce3c105cf}"
  DisplayName="employee" Type="Lookup" List="Lists/Employee" 
  ShowField="Address" EnableLookup="TRUE" WebId="~sitecollection" />

(This is assuming your lookup list is on the root site of the site collection, if this is not the case, change the WebId parameter as required)

Also, as already stated, check that the lookup list is available before the column is created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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