Export (0) Print
Expand All

CrmService Common Methods

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

The CrmService Web service provides a set of methods used to perform the most common operations on system and custom entities. These operations can also be performed by using the Execute method and the corresponding message. However, the methods will perform faster so they should be used whenever possible.

The following table gives a description for each of these methods.

MethodDescription
Create Creates an instance of any entity that supports the Create message, including custom entities.
Retrieve Retrieves an instance of an entity.
RetrieveMultiple Uses a custom query (QueryExpression) to retrieve strongly typed results.
Update Updates an existing entity instance.
Delete Deletes an existing entity instance.
Fetch Use a custom query (FetchXML) to retrieve results in XML format

Example

The following code shows how to set up the Web service, and how to use the Create and Retrieve methods.

// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
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 an account entity and assign data to some attributes.
account newAccount = new account();
newAccount.name = "Greg Bike Store";
newAccount.accountnumber = "123456";
newAccount.address1_postalcode = "98052";
newAccount.address1_city = "Redmond";

// Call the Create method to create an account.
Guid accountId = service.Create(newAccount);

Guid contactId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

// Call the Retrieve method to retrieve an existing contact.
ColumnSet myColumnSet = new ColumnSet();
myColumnSet.Attributes = new string[] { "firstname" };
contact myContact = (contact) service.Retrieve ("contact", contactId, myColumnSet)

See Also

Concepts

Other Resources


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2015 Microsoft