Κοινή χρήση μέσω


UpdateRequest Class

 

Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

Contains the data that is needed to update an existing record.

Namespace:   Microsoft.Xrm.Sdk.Messages
Assembly:  Microsoft.Xrm.Sdk (in Microsoft.Xrm.Sdk.dll)

Inheritance Hierarchy

System.Object
  Microsoft.Xrm.Sdk.OrganizationRequest
    Microsoft.Xrm.Sdk.Messages.UpdateRequest

Syntax

[DataContractAttribute(Namespace = "https://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class UpdateRequest : OrganizationRequest
<DataContractAttribute(Namespace := "https://schemas.microsoft.com/xrm/2011/Contracts")>
Public NotInheritable Class UpdateRequest
    Inherits OrganizationRequest

Constructors

Name Description
System_CAPS_pubmethod UpdateRequest()

Initializes a new instance of the UpdateRequest class.

Properties

Name Description
System_CAPS_pubproperty ConcurrencyBehavior

Specifies the type of optimistic concurrency behavior that should be performed by the Web service when processing this request.

System_CAPS_pubproperty ExtensionData

Gets or sets the structure that contains extra data. Optional.(Inherited from OrganizationRequest.)

System_CAPS_pubproperty Item[String]

Gets or sets the indexer for the Parameters collection.(Inherited from OrganizationRequest.)

System_CAPS_pubproperty Parameters

Gets or sets the collection of parameters for the request. Required, but is supplied by derived classes.(Inherited from OrganizationRequest.)

System_CAPS_pubproperty RequestId

Gets or sets the ID of an asynchronous operation (system job). Optional. (Inherited from OrganizationRequest.)

System_CAPS_pubproperty RequestName

Gets or sets the name of the request. Required, but is supplied by derived classes.(Inherited from OrganizationRequest.)

System_CAPS_pubproperty Target

Gets or sets an instance of an entity that is used to update a record. Required.

Methods

Name Description
System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_pubmethod ToString()

(Inherited from Object.)

Remarks

Message Availability

This message works regardless whether the caller is connected to the server or offline. Not all entity types support this message offline. For more information, see Supported Entities later in this topic.

Usage

Pass an instance of this class to the Execute method, which returns an instance of the UpdateResponse class.

This message supports one or more optional parameters. For more information, see Use messages (request and response classes) with the Execute method.

Privileges and Access Rights

To perform this action, the caller must have privileges on the specified entity in the entity parameter. For a list of the required privileges, see Update message privileges.

Notes for Callers

This message updates a record and its related records in one transaction. For a less complex method that updates a single record, use the Update method.

If the entity instance that is specified in the Target parameter includes attributes that are not valid for update, they are ignored.

Supported Entities

You can use this method to update any record of an entity that supports the Update message, including custom entities.

The following table shows the default entities that support this message. For the listed entities of this message, the Availability column shows Server if the caller must be connected to the server and shows Both if the caller can be either connected to, or disconnected from, the server.

Entity

Availability

Account

2 (Both)

ActivityMimeAttachment

2 (Both)

Annotation

2 (Both)

AnnualFiscalCalendar

2 (Both)

Appointment

2 (Both)

AsyncOperation

2 (Both)

BusinessUnit

2 (Both)

BusinessUnitNewsArticle

2 (Both)

Calendar

2 (Both)

Campaign

2 (Both)

CampaignActivity

2 (Both)

CampaignResponse

2 (Both)

Competitor

2 (Both)

Connection

2 (Both)

ConnectionRole

2 (Both)

ConstraintBasedGroup

2 (Both)

Contact

2 (Both)

Contract

2 (Both)

ContractDetail

2 (Both)

ContractTemplate

2 (Both)

ConvertRule

2 (Both)

ConvertRuleItem

2 (Both)

CustomerAddress

2 (Both)

CustomerOpportunityRole

2 (Both)

CustomerRelationship

2 (Both)

Discount

2 (Both)

DiscountType

2 (Both)

DisplayString

2 (Both)

DuplicateRule

2 (Both)

DuplicateRuleCondition

2 (Both)

DynamicProperty

2 (Both)

DynamicPropertyAssociation

2 (Both)

DynamicPropertyInstance

2 (Both)

DynamicPropertyOptionSetItem

2 (Both)

Email

2 (Both)

EmailServerProfile

2 (Both)

Entitlement

2 (Both)

EntitlementChannel

2 (Both)

EntitlementTemplate

2 (Both)

EntitlementTemplateChannel

2 (Both)

Equipment

2 (Both)

ExchangeSyncIdMapping

2 (Both)

Fax

2 (Both)

FieldPermission

2 (Both)

FieldSecurityProfile

2 (Both)

FixedMonthlyFiscalCalendar

2 (Both)

Goal

2 (Both)

GoalRollupQuery

2 (Both)

HierarchyRule

2 (Both)

Import

2 (Both)

ImportFile

2 (Both)

ImportJob

2 (Both)

ImportMap

2 (Both)

Incident

2 (Both)

IncidentResolution

2 (Both)

Invoice

2 (Both)

InvoiceDetail

2 (Both)

IsvConfig

2 (Both)

KbArticle

2 (Both)

KbArticleComment

2 (Both)

KbArticleTemplate

2 (Both)

Lead

2 (Both)

Letter

2 (Both)

List

2 (Both)

Mailbox

2 (Both)

MailMergeTemplate

2 (Both)

Metric

2 (Both)

MonthlyFiscalCalendar

2 (Both)

msdyn_PostAlbum

2 (Both)

msdyn_PostConfig

2 (Both)

msdyn_PostRuleConfig

2 (Both)

msdyn_wallsavedquery

2 (Both)

msdyn_wallsavedqueryusersettings

2 (Both)

Opportunity

2 (Both)

OpportunityClose

2 (Both)

OpportunityProduct

2 (Both)

OrderClose

2 (Both)

Organization

2 (Both)

OrganizationUI

2 (Both)

PhoneCall

2 (Both)

PluginAssembly

2 (Both)

PluginType

2 (Both)

Position

2 (Both)

PriceLevel

2 (Both)

PrincipalObjectAttributeAccess

2 (Both)

ProcessSession

2 (Both)

ProcessTrigger

2 (Both)

Product

2 (Both)

ProductAssociation

2 (Both)

ProductPriceLevel

2 (Both)

ProductSubstitute

2 (Both)

Publisher

2 (Both)

PublisherAddress

2 (Both)

QuarterlyFiscalCalendar

2 (Both)

Queue

2 (Both)

QueueItem

2 (Both)

Quote

2 (Both)

QuoteClose

2 (Both)

QuoteDetail

2 (Both)

RecurrenceRule

2 (Both)

RecurringAppointmentMaster

2 (Both)

RelationshipRole

2 (Both)

RelationshipRoleMap

2 (Both)

Report

2 (Both)

ReportCategory

2 (Both)

ReportEntity

2 (Both)

ReportVisibility

2 (Both)

ResourceSpec

2 (Both)

Role

2 (Both)

RollupField

2 (Both)

RoutingRule

2 (Both)

RoutingRuleItem

2 (Both)

SalesLiterature

2 (Both)

SalesLiteratureItem

2 (Both)

SalesOrder

2 (Both)

SalesOrderDetail

2 (Both)

SavedQuery

2 (Both)

SavedQueryVisualization

2 (Both)

SdkMessageProcessingStep

2 (Both)

SdkMessageProcessingStepImage

2 (Both)

SdkMessageProcessingStepSecureConfig

2 (Both)

SemiAnnualFiscalCalendar

2 (Both)

Service

2 (Both)

ServiceAppointment

2 (Both)

ServiceEndpoint

2 (Both)

SharePointData

2 (Both)

SharePointDocumentLocation

2 (Both)

SharePointSite

2 (Both)

Site

2 (Both)

SiteMap

2 (Both)

SLA

2 (Both)

SLAItem

2 (Both)

SLAKPIInstance

2 (Both)

SocialActivity

2 (Both)

SocialInsightsConfiguration

2 (Both)

SocialProfile

2 (Both)

Solution

2 (Both)

Subject

2 (Both)

SystemForm

2 (Both)

SystemUser

2 (Both)

Task

2 (Both)

Team

2 (Both)

TeamTemplate

2 (Both)

Template

2 (Both)

Territory

2 (Both)

TransactionCurrency

2 (Both)

UoM

2 (Both)

UoMSchedule

2 (Both)

UserEntityInstanceData

2 (Both)

UserEntityUISettings

2 (Both)

UserForm

2 (Both)

UserQuery

2 (Both)

UserQueryVisualization

2 (Both)

UserSettings

2 (Both)

WebResource

2 (Both)

Workflow

2 (Both)

WorkflowDependency

2 (Both)

WorkflowLog

2 (Both)

Examples

The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface. For the complete sample, see the link later in this topic.



// Retrieve current price list
ProductPriceLevel priceListItem =
    (ProductPriceLevel)_serviceProxy.Retrieve(
        ProductPriceLevel.EntityLogicalName,
        _priceListItemId,
        new ColumnSet("productpricelevelid", "amount")
    );

Console.WriteLine("Current price list retrieved.");
Console.WriteLine();

Console.WriteLine("Details before update:");
Console.WriteLine("----------------");
Console.WriteLine("Current order total: {0}",
    salesOrder.TotalAmount.Value);
Console.WriteLine("Current price per item: {0}",
    priceListItem.Amount.Value);
Console.WriteLine("</End of Listing>");
Console.WriteLine();

// Update the price list
priceListItem.Amount = new Money(30.0M);

UpdateRequest updatePriceListItem = new UpdateRequest()
{
    Target = priceListItem,
};
_serviceProxy.Execute(updatePriceListItem);

Console.WriteLine("Price list updated.");


' Retrieve current price list
Dim priceListItem As ProductPriceLevel =
    CType(_serviceProxy.Retrieve(ProductPriceLevel.EntityLogicalName,
                                 _priceListItemId,
                                 New ColumnSet("productpricelevelid", "amount")), 
                             ProductPriceLevel)

Console.WriteLine("Current price list retrieved.")
Console.WriteLine()

Console.WriteLine("Details before update:")
Console.WriteLine("----------------")
Console.WriteLine("Current order total: {0}",
                  salesOrder_Renamed.TotalAmount.Value)
Console.WriteLine("Current price per item: {0}",
                  priceListItem.Amount.Value)
Console.WriteLine("</End of Listing>")
Console.WriteLine()

' Update the price list
priceListItem.Amount = New Money(30D)

Dim updatePriceListItem As New UpdateRequest() With {.Target = priceListItem}
_serviceProxy.Execute(updatePriceListItem)

Console.WriteLine("Price list updated.")

Thread Safety

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Microsoft.Xrm.Sdk.Messages Namespace
Extend Microsoft Dynamics 365 on the server
Sample: Process quotes, sales orders and invoices

Return to top

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright