Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

RelatedField class

Specifies a relationship to a lookup field.


Namespace:  Microsoft.SharePoint.Client
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)
public class RelatedField : ClientObject

This code example displays the identifier of fields related to the Tasks list of the specified site.

using System;
using Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointFoundation.Samples
    class RelatedFieldExample
        static void Main()
            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            Web site = clientContext.Web;

            List targetList = site.Lists.GetByTitle("Tasks");

            // Get a collection of lookup fields that use this list as a data source 
            // and that have FieldLookup.IsRelationship set to true.
            RelatedFieldCollection collRelatedField = targetList.GetRelatedFields();


            foreach (RelatedField relField in collRelatedField)
               Console.WriteLine("Related Field ID: {0}", relField.FieldId);

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.