This documentation is archived and is not being maintained.

RetrieveBusinessHierarchyBusinessUnit Message (CrmService)

Forefront
banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

Works for all deployment typesWorks online only

Retrieves all business units (including the specified business unit) in the business unit hierarchy.

The relevant classes are specified in the following table.

TypeClass
RequestRetrieveBusinessHierarchyBusinessUnitRequest
ResponseRetrieveBusinessHierarchyBusinessUnitResponse
Entitybusinessunit

Remarks

To use this message, pass an instance of the RetrieveBusinessHierarchyBusinessUnitRequest class as the request parameter in the Execute method.

To perform this action, the caller must have access rights on the business unit entity instance. For a list of required privileges, see RetrieveBusinessHierarchyBusinessUnit Privileges.

Example

The following code example demonstrates how to use the RetrieveBusinessHierarchyBusinessUnit message.

[C#]
// Set up the CRM service.
CrmAuthenticationToken token = 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";
 
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the column set.
ColumnSet cols = new ColumnSet();

// Set the properties of the column set.
cols.Attributes = new string [] {"name"};

// Create the request object.
RetrieveBusinessHierarchyBusinessUnitRequest retrieve = new RetrieveBusinessHierarchyBusinessUnitRequest();

// Set the properties of the request object.
retrieve.ColumnSet = cols;
retrieve.EntityId = new Guid("18ECA720-493E-4800-BBFD-638BD54EB325");

// Execute the request.
RetrieveBusinessHierarchyBusinessUnitResponse retrieved = (RetrieveBusinessHierarchyBusinessUnitResponse) service.Execute(retrieve);
[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"
 
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx"
service.CrmAuthenticationTokenValue = token
service.Credentials = System.Net.CredentialCache.DefaultCredentials

' Create the column set.
Dim cols As New ColumnSet()

' Set the properties of the column set.
cols.Attributes = New String() {"name"}

' Create the request object.
Dim retrieve As New RetrieveBusinessHierarchyBusinessUnitRequest()

' Set the properties of the request object.
retrieve.ColumnSet = cols
retrieve.EntityId = New Guid("18ECA720-493E-4800-BBFD-638BD54EB325")

' Execute the request.
Dim retrieved As RetrieveBusinessHierarchyBusinessUnitResponse = CType(service.Execute(retrieve), RetrieveBusinessHierarchyBusinessUnitResponse)

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show: