Lookup fields in contentype

Nov 26, 2008 at 7:00 PM
Edited Nov 27, 2008 at 9:23 AM
Hi!

I´m having problemes deploying a content type with a field of type lookup.
The lookup filed should be related to two other lists that I´m deploying.

I´ve read a lot of different this about the List attribute, from  List="Lists/myList" to List="{xxxx-xx...}" (guid).
FieldRef and ShowField is optional, the title field should be deafult.

Now I´m down to making the lookup filed in a feature receiver, I works but it doesn´t feel right.

Any hints on this topic ?





Developer
Nov 26, 2008 at 9:19 PM
you probably wouldn't be able to provide a List GUID. Those Guids are automatically generated and assigned after a list instance is created in a site. So during development time you would have no idea what the Guid for the list id will be. And the guids also change from site to site.
Nov 27, 2008 at 9:35 AM

As I guessed, with the guids.

But, I´m having trouble with the other way, List="Lists/myList" too.

I´ve read serveral posts about people solving these as I do with a FeatureReceiver. It works, but it would be better if it were possible to get to work from the content type diffention.

It would be appreciated if anyone know of a sample of this or further infomation on the subject.

Thanks!

 

Developer
Dec 1, 2008 at 7:18 PM
An example of a lookup field would look something like below:

<Field ID="{3B55D35D-410A-4a4c-8F74-C349A83CA5D8}" Type="Lookup" Name="MyCourses" DisplayName="My Courses" List="Lists/TrainingCourses" ShowField="Title" />

The two attributes you must define are List and ShowField. The Type has to be "Lookup". You can define the field as either a list column or a site column. I hope that helps.