Export (0) Print
Expand All

CrmService.Update Method

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Updates an instance of an entity.

Syntax

[Visual Basic .NET]
Public Sub Update(
  ByVal entity As BusinessEntity
)
[C#]
public void Update(
  BusinessEntity  entity
);

Parameters

entity

Specifies an instance of a class derived from BusinessEntity of a type that supports updating. The instance has one or more property values that are to be updated.

Return Value

No return value.

Remarks

Use this method to update any instance of a Microsoft Dynamics CRM entity that supports the Update message.

For better performance, use this method instead of using the Execute method with the Update message.

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 Update Privileges.

Example

The following example demonstrates the use of the Update method.

[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 contact object.
contact contact = new contact();

// Set the contact object properties to be updated.
contact.address1_line1 = "34 Market St.";

// The contactid is a key that references the ID of the contact to be updated.
contact.contactid = new Key();
// The contactid.Value is the GUID of the record to be changed.
contact.contactid.Value = new Guid("4D507FFE-ED25-447B-80DE-00AE3EB18B84");

// Update the contact.
service.Update(contact);
[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 contact object.
Dim contact As New contact()

' Set the contact object properties to be updated.
contact.address1_line1 = "34 Market St."

' The contactid is a key that references the ID of the contact to be updated.
contact.contactid = New Key()
' The contactid.Value is the GUID of the record to be changed.
contact.contactid.Value = new Guid("4D507FFE-ED25-447B-80DE-00AE3EB18B84");

' Update the contact.
service.Update(contact)

Requirements

Namespace: CrmService

See Also

Concepts

Tasks

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft