SharePoint Foundation’s SPList API now contain’s a method which can be used to retrieve a SPList’s “Related Fields”. This method returns a collection of SPRelatedFields representing all the Lookup Columns pointing to the SPList in question. This methods can be used as the basis for writing a useful extension method on SPList which retrieves a collection, specifically in this case a generic List<SPListItem>.

The Code Snippet below shows the code that will ultimately return the entire collection of ListItems that related to the SPListItem the method is called on:

code01

The following Code Snippet demonstrates usage of this extension method in a Console Application. The ConsoleApplication is targeting a SPWeb that has 3 lists. The List titled “Target” is reference by two related lists:
 
code02
The image below shows the console output when the code above is run:
screen
Categorieën: Nieuws
Tags:

Geef een reactie

Jouw e-mailadres wordt niet gepubliceerd. Verplichte velden zijn gemarkeerd met *

*

De volgende HTML tags en attributen zijn toegestaan: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Categories

  • Tags

  • Blog Authors

    Amy
    anita
    Anneke
    Danny Burlage
    Dennis Vendel
    Freek Berson
    Gerard
    Iris
    Jasper Oosterveld
    Jean-Claude Chan
    Jorn
    Lab Chicks
    Luc Joziasse
    Maarten van Noort
    Maarten Wijsman
    Marlon
    Martijn Bellaard
    Natasja van Doorn
    Paul Pascha
    Peter Heuvelman
    Rick Slager
    Robert van Son
    Roeland Jimenez
    SanderZ
    Sjoerd Schudde
    Stefan van der Wiele
    Tim Heuperman
    Wortell
  • Archief