List.GetRelatedFields method
SharePoint 2013
Returns a collection of lookup fields that use this list as a data source and that have FieldLookup.IsRelationship set to true.
Assemblies: Microsoft.SharePoint.Client.Silverlight (in Microsoft.SharePoint.Client.Silverlight.dll); Microsoft.SharePoint.Client.Phone (in Microsoft.SharePoint.Client.Phone.dll) Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)
Return value
Type: Microsoft.SharePoint.Client.RelatedFieldCollectionReturns a RelatedFieldCollection instance representing the collection of lookup fields that use this list as a data source and that have FieldLookup.IsRelationship set to true.
This code example displays the identifier of any fields related to the current site’s Tasks list.
using System; using Microsoft.SharePoint.Client; namespace Microsoft.SDK.SharePointFoundation.Samples { class List_getRelatedFieldsExample { static void Main() { string siteUrl = "http://MyServer/sites/MySiteCollection"; ClientContext clientContext = new ClientContext(siteUrl); Web site = clientContext.Web; List targetList = site.Lists.GetByTitle("Tasks"); RelatedFieldCollection collRelatedField = targetList.GetRelatedFields(); clientContext.Load(collRelatedField); clientContext.ExecuteQuery(); foreach (RelatedField targetField in collRelatedField) Console.WriteLine("Related Field ID: {0}", targetField.FieldId); } } } }