Export (0) Print
Expand All

GetValidManyToMany Message (MetadataService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Works for all deployment typesWorks online only

Returns the set of entities that can participate in a many-to-many relationship.

The relevant classes are specified in the following table.

TypeClass
RequestGetValidManyToManyRequest
ResponseGetValidManyToManyResponse

Remarks

To perform this action, the caller must be a user in the organization for which metadata is requested and must have Read Attribute, Read Entity and Read Relationship privileges.

Example

The following example shows how to use the GetValidManyToMany message.

[C#]
// Create an authentication token.
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.OrganizationName = "AdventureWorksCycle";

// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0; 

// Create the metadata Web service;
MetadataService metadataService = new MetadataService();
metadataService.Url = "http://<servername>:<port>/MSCRMServices/2007/MetadataService.asmx";
metadataService.CrmAuthenticationTokenValue = token;
metadataService.Credentials = System.Net.CredentialCache.DefaultCredentials;
metadataService.PreAuthenticate = true;

// Create the request.
GetValidManyToManyRequest validM2MRequest = new GetValidManyToManyRequest();

// Execute the request.
GetValidManyToManyResponse validM2MResponse = (GetValidManyToManyResponse)metadataService.Execute(validM2MRequest);

// Determine if the Contact entity can participate in a many-to-many relationship.
bool bContactEntityFound = false;

foreach (string entityName in validM2MResponse.EntityNames)
{
   if (entityName == EntityName.contact.ToString())
   {
      bContactEntityFound = true;
   }
}

[Visual Basic .NET]
' Set up the CRM Service.
Dim token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";

// Create the metadata Web service.
Dim metadataService As New MetadataService ()
metadataService.Url = "http://<servername>:<port>/mscrmservices/2007/MetadataService.asmx";
metadataService.CrmAuthenticationTokenValue = token;
metadataService.Credentials = System.Net.CredentialCache.DefaultCredentials
metadataService.PreAuthenticate = true;

' Create the request.
Dim validM2MRequest As New GetValidManyToManyRequest()

' Execute the request.
Dim validM2MResponse As GetValidManyToManyResponse = CType(metadataService.Execute(validM2MRequest), GetValidManyToManyResponse)

' Determine if the Contact entity can participate in a many-to-many relationship.
Dim bContactEntityFound As Boolean = False

For Each entityName As String In validM2MResponse.EntityNames
   If entityName = CrmSdk.EntityName.contact.ToString() Then
      bContactEntityFound = True
   End If
Next entityName

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft