2

I'm struggling with the declarative creation of a lookup field:

  <Field ID="{3EA24157-1C11-41CB-AA01-5EEEF93C2603}"
      Name="NewField"
      DisplayName="New Field"
      StaticName="NewField"
      DisplaceOnUpgrade="TRUE"
      Group="New Columns"
      ShowField="ID"
      List="Lists/Cars"
      Type="Lookup"
      Required="TRUE"/>

NewField points to the field ID in the list Cars.

I'm using 3 feature: 1 -> Module(Fields) 2 -> New List Definition 3 -> New List Instance

The list Cars is already present.

Why the lookup field doesn't work? 1)The Field pointed by the lookup is misspelled or not exist. 2)The List pointed by the lookup is misspelled or not exist.

Are there any other reasons to justify the problem?

UPDATE: As Arsal said the List have to exist before that the field si loaded.i.e. if you load the field by, for example, a feature in the exact moment when you activate it and the field is loaded, the POINTED list has to be already declared (as well as the target field) otherwise the lookup fails and there's no chance to fix it even reactiving the involved feartures.

Another difference of the declarative creation of a look up is that: in the case that the target list is empty the lookup appears as broken, so you cannot trust on the appearance for this reason you are obliged to add an item to the target list and verify.

1

Need to set the WebId attribute when deploying declarative.. Assuming the root site contains the Parent List, following should work:

List="Lists/Cars" WebId="~sitecollection" ShowField="Title" PrependId="TRUE"

If the list is also declarative and generated via List Instance.. Need to make sure the List exists before the Lookup column is created..

Your Answer

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