This documentation is archived and is not being maintained.

Update 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 and offline

Updates an instance of an entity.

The relevant classes are specified in the following table.

TypeClass
RequestUpdateRequest
ResponseUpdateResponse
TargetTargetUpdate
Optional ParametersCreateDuplicatesOptionalParameter

PersistInSyncOptionalParameter

RequestIdOptionalParameter

EntitySee below.

The following table shows the entities and target classes for this message.

EntityTarget class
accountTargetUpdateAccount
activitymimeattachmentTargetUpdateActivityMimeAttachment
annotationTargetUpdateAnnotation
annualfiscalcalendarTargetUpdateAnnualFiscalCalendar
appointmentTargetUpdateAppointment
asyncoperationTargetUpdateAsyncOperation
businessunitTargetUpdateBusinessUnit
businessunitnewsarticleTargetUpdateBusinessUnitNewsArticle
calendarTargetUpdateCalendar
campaignTargetUpdateCampaign
campaignactivityTargetUpdateCampaignActivity
campaignresponseTargetUpdateCampaignResponse
competitorTargetUpdateCompetitor
constraintbasedgroupTargetUpdateConstraintBasedGroup
contactTargetUpdateContact
contractTargetUpdateContract
contractdetailTargetUpdateContractDetail
contracttemplateTargetUpdateContractTemplate
Custom entityTargetUpdateX where X is the name of the custom entity
customeraddressTargetUpdateCustomerAddress
customeropportunityroleTargetUpdateCustomerOpportunityRole
customerrelationshipTargetUpdateCustomerRelationship
discountTargetUpdateDiscount
discounttypeTargetUpdateDiscountType
displaystringTargetUpdateDisplayString
duplicateruleTargetUpdateDuplicateRule
duplicateruleconditionTargetUpdateDuplicateRuleCondition
DynamicEntityTargetUpdateDynamic
emailTargetUpdateEmail
equipmentTargetUpdateEquipment
faxTargetUpdateFax
fixedmonthlyfiscalcalendarTargetUpdateFixedMonthlyFiscalCalendar
importTargetUpdateImport
importfileTargetUpdateImportFile
importmapTargetUpdateImportMap
incidentTargetUpdateIncident
incidentresolutionTargetUpdateIncidentResolution
invoiceTargetUpdateInvoice
invoicedetailTargetUpdateInvoiceDetail
isvconfigTargetUpdateIsvConfig
kbarticleTargetUpdateKbArticle
kbarticlecommentTargetUpdateKbArticleComment
kbarticletemplateTargetUpdateKbArticleTemplate
leadTargetUpdateLead
letterTargetUpdateLetter
listTargetUpdateList
mailmergetemplateTargetUpdateMailMergeTemplate
monthlyfiscalcalendarTargetUpdateMonthlyFiscalCalendar
opportunityTargetUpdateOpportunity
opportunitycloseTargetUpdateOpportunityClose
opportunityproductTargetUpdateOpportunityProduct
ordercloseTargetUpdateOrderClose
organizationTargetUpdateOrganization
organizationuiTargetUpdateOrganizationUI
phonecallTargetUpdatePhoneCall
pluginassemblyTargetUpdatePluginAssembly
plugintypeTargetUpdatePluginType
pricelevelTargetUpdatePriceLevel
productTargetUpdateProduct
productpricelevelTargetUpdateProductPriceLevel
quarterlyfiscalcalendarTargetUpdateQuarterlyFiscalCalendar
queueTargetUpdateQueue
quoteTargetUpdateQuote
quotecloseTargetUpdateQuoteClose
quotedetailTargetUpdateQuoteDetail
relationshiproleTargetUpdateRelationshipRole
relationshiprolemapTargetUpdateRelationshipRoleMap
reportTargetUpdateReport
reportcategoryTargetUpdateReportCategory
reportentityTargetUpdateReportEntity
reportvisibilityTargetUpdateReportVisibility
resourcespecTargetUpdateResourceSpec
roleTargetUpdateRole
salesliteratureTargetUpdateSalesLiterature
salesliteratureitemTargetUpdateSalesLiteratureItem
salesorderTargetUpdateSalesOrder
salesorderdetailTargetUpdateSalesOrderDetail
savedqueryTargetUpdateSavedQuery
sdkmessageprocessingstepTargetUpdateSdkMessageProcessingStep
sdkmessageprocessingstepimage TargetUpdateSdkMessageProcessingStepImage
sdkmessageprocessingstepsecureconfigTargetUpdateSdkMessageProcessingStepSecureConfig
semiannualfiscalcalendarTargetUpdateSemiAnnualFiscalCalendar
serviceTargetUpdateService
serviceappointmentTargetUpdateServiceAppointment
siteTargetUpdateSite
subjectTargetUpdateSubject
systemuserTargetUpdateSystemUser
taskTargetUpdateTask
teamTargetUpdateTeam
templateTargetUpdateTemplate
territoryTargetUpdateTerritory
transactioncurrencyTargetUpdateTransactionCurrency
uomTargetUpdateUoM
uomscheduleTargetUpdateUoMSchedule
userqueryTargetUpdateUserQuery
workflowTargetUpdateWorkflow
workflowdependencyTargetUpdateWorkflowDependency
workflowlogTargetUpdateWorkflowLog

Remarks

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

If the entity instance specified in the target includes attributes that are not valid for update, they will be ignored.

To perform this action, the caller access rights on the entity instance specified in the request class. For a list of required privileges, see Update Privileges.

You can use the Metadata Browser to determine which fields are valid for update in each entity. Also, the topic for each attribute contains this information.

Example

The following code example shows how to use the Update 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 account object.
account account = new account();

// Set the properties of the account object to be updated.
account.address1_line1 = "34 Market St.";
account.creditlimit = new CrmMoney();
account.creditlimit.Value = 500000;

// accountid is a key that references the ID of the account to be updated.
account.accountid = new Key();
// accountid.Value is the GUID of the record to be changed.
account.accountid.Value = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

// Create the target object for the request.
TargetUpdateAccount target = new TargetUpdateAccount();

// Set the properties of the target object.
target.Account = account;

// Create the request object.
UpdateRequest update = new UpdateRequest();

// Set the properties of the request object.
update.Target = target;
   
// Execute the request.
UpdateResponse updated = (UpdateResponse)service.Execute(update);
[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 account object.
Dim account As New account()

' Set the properties of the account object to be updated.
account.address1_line1 = "34 Market St."
account.creditlimit = New CrmMoney()
account.creditlimit.Value = 500000

' accountid is a key that references the ID of the account to be updated.
account.accountid = New Key()
' accountid.Value is the GUID of the record to be changed.
account.accountid.Value = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

' Create the target object for the request.
Dim target As New TargetUpdateAccount()

' Set the properties of the target object.
target.Account = account

' Create the request object.
Dim update As New UpdateRequest()

' Set the properties of the request object.
update.Target = target

' Execute the request.
Dim updated As UpdateResponse = CType(service.Execute(update), UpdateResponse)

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show: