Is there any solid (proven) method of creating Site columns (lookups) where list GUID is not known?
I think this is where feature activation kicks in; getting the lookup list by its name and then using the GUID to create the lookup.
|
Is there any solid (proven) method of creating Site columns (lookups) where list GUID is not known? I think this is where feature activation kicks in; getting the lookup list by its name and then using the GUID to create the lookup. |
||||
|
|
|
Isn't too difficult really, in the FeatureActivated method, you just create a new SPieldLookup (using SPWeb.Fields.AddLookup() for the SPSite's RootWeb), and set the properties for the SPFieldLookup as required. First time doing it? Bit tricky if you've never made a FeatureReceiver before, let me know if you need a tutorial do that, and here's some sample code that should get you started (this will create a field that matches to "Title" of "My List") [also, this needs to be a FeatureReceiver for a Site Collection -scoped Feature];
|
|||||
|
|
Take a look at this article: Declaratively adding a lookup field to a list schema using the name of the referenced list |
||||
|
|