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

CanBeReferencingRequest Class

[Applies to: Microsoft Dynamics CRM 2011]

Contains the data that is needed to check whether an entity can be the referencing entity in a one-to-many relationship.

Namespace: Microsoft.Xrm.Sdk.Messages
Assembly: Microsoft.Xrm.Sdk (in Microsoft.Xrm.Sdk.dll)

public sealed class CanBeReferencingRequest : OrganizationRequest

The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface. For the complete sample, see the link later in this topic.

/// <summary>
/// Determines whether two entities are eligible to participate in a relationship
/// </summary>
/// <param name="referencedEntity">Primary Entity</param>
/// <param name="referencingEntity">Referencing Entity</param>
/// <returns></returns>
public bool EligibleCreateOneToManyRelationship(string referencedEntity, 
    string referencingEntity)
    //Checks whether the specified entity can be the primary entity in one-to-many
    CanBeReferencedRequest canBeReferencedRequest = new CanBeReferencedRequest
        EntityName = referencedEntity

    CanBeReferencedResponse canBeReferencedResponse =

    if (!canBeReferencedResponse.CanBeReferenced)
            "Entity {0} can't be the primary entity in this one-to-many relationship", 

    //Checks whether the specified entity can be the referencing entity in one-to-many
    CanBeReferencingRequest canBereferencingRequest = new CanBeReferencingRequest
        EntityName = referencingEntity

    CanBeReferencingResponse canBeReferencingResponse =

    if (!canBeReferencingResponse.CanBeReferencing)
            "Entity {0} can't be the referencing entity in this one-to-many relationship", 

    if (canBeReferencedResponse.CanBeReferenced == true
        && canBeReferencingResponse.CanBeReferencing == true)
        return true;
        return false;

Message Availability

For this message to work, the caller must be connected to the server.


Pass an instance of this class to the Execute method, which returns an instance of the CanBeReferencingResponse class.

Privileges and Access Rights

To perform this action, the caller must have the required privileges, as listed in CanBeReferencing Privileges.

Notes for Callers

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Server 2008

Target Platforms

Windows Server 2008, Windows 7 (All Versions), Windows Vista (All Versions)

Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.