Retrieve Message (CrmService)
![]() |
[Applies to: Microsoft Dynamics CRM 4.0]
| Works for all deployment types | Works online and offline |
Retrieves a business entity instance with the specified ID.
The relevant classes are specified in the following table.
| Type | Class |
| Request | RetrieveRequest |
| Response | RetrieveResponse |
| Target | TargetRetrieve |
| Entity | See the following table. |
The following table shows the entities and target classes for this message.
Remarks
To use this message, pass an instance of the RetrieveRequest class as the request parameter in the Execute method.
If the columnset includes attributes that are not valid for retrieve, they will be ignored.
To perform this action, the caller must have access rights on the entity instance specified in the request class. For a list of required privileges, see Retrieve Privileges.
For better performance, use the Retrieve method instead of using this message.
Example
The following code example shows how to use the Retrieve 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 object that indicates the fields to be retrieved.
ColumnSet cols = new ColumnSet();
// Set the properties of the column set.
cols.Attributes = new string [] {"name"};
// Create the target object for the request.
TargetRetrieveAccount target = new TargetRetrieveAccount();
// Set the properties of the target object.
// EntityId is the GUID of the record being retrieved.
target.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");
// Create the request object.
RetrieveRequest retrieve = new RetrieveRequest();
// Set the properties of the request object.
retrieve.Target = target;
retrieve.ColumnSet = cols;
// Execute the request.
RetrieveResponse retrieved = (RetrieveResponse)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 object that indicates the fields to be retrieved.
Dim cols As New ColumnSet()
' Set the properties of the column set.
cols.Attributes = New String() {"name"}
' Create the target object for the request.
Dim target As New TargetRetrieveAccount()
' Set the properties of the target object.
' EntityId is the GUID of the record being retrieved.
target.EntityId = New Guid("2B951FBC-1C56-4430-B23B-20A1349068F3")
' Create the request object.
Dim retrieve As New RetrieveRequest()
' Set the properties of the request object.
retrieve.Target = target
retrieve.ColumnSet = cols
' Execute the request.
Dim retrieved As RetrieveResponse = CType(service.Execute(retrieve), RetrieveResponse)
See Also
Reference
© 2010 Microsoft Corporation. All rights reserved.
