Is there a way get lookup fields in random lists associated with a specific list programmatically?

553 views Asked by At

I have a sharepoint list, for example it is named as SourceList. I also have several lists which are associated to SourceList via lookup fields. I don't know the names or number of these lists\ they are created and being created dynamically. And any time a new list associated to SourceList can be created.

So, how can i get the lists associated to SourceList programmatically by Sharepoint object model? I know that i can iterate through lists and also the fields of the lists to check if it is a lookup field and associated to my SourceList. I don't want to do this for performance concerns but it will be my last chance if i can't find a better solution. And also i know i can query sharepoint db directly to get these lists but i will never want to do this.

Thanks.

1

There are 1 answers

0
str8killinit On

You basically just need to access the list then the lookup field which should be of type SPFieldLookup when you have this object the source list will be the LookupList property on that field.

They have a good example in this link:

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfieldlookup.aspx