共用方式為


DeleteOpenInstancesRequest Class

 

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

Contains the data that is needed to delete instances of a recurring appointment master that have an “Open” state.

For the Web API use the DeleteOpenInstances Action.

Namespace:   Microsoft.Crm.Sdk.Messages
Assembly:  Microsoft.Crm.Sdk.Proxy (in Microsoft.Crm.Sdk.Proxy.dll)

Inheritance Hierarchy

System.Object
  Microsoft.Xrm.Sdk.OrganizationRequest
    Microsoft.Crm.Sdk.Messages.DeleteOpenInstancesRequest

Syntax

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

Constructors

Name Description
System_CAPS_pubmethod DeleteOpenInstancesRequest()

Initializes a new instance of the DeleteOpenInstancesRequest class.

Properties

Name Description
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 SeriesEndDate

Gets or sets the end date for the recurring appointment series. Required.

System_CAPS_pubproperty StateOfPastInstances

Gets or sets the value to be used to set the status of appointment instances that have already passed. Required.

System_CAPS_pubproperty Target

Gets or sets the target record for the operation. 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.

Usage

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

Privileges and Access Rights

To perform this action, the caller must have privileges on the entity specified in the Target property and access rights on the record specified in the Target property. For a list of the privileges required, see DeleteOpenInstances message privileges.

Notes for Callers

Using this message does the following:

  • Deletes all the “open” and “scheduled” future instances of the specified series from the date specified in the SeriesEndDate property. However, if the state of the future instances is changed to “completed” or “canceled”, they are not deleted.

  • Sets the status of the past instances to the specified value in the StateOfPastInstances property. However, the past instances are not deleted.

  • Terminates the series to the last occurring past instance date with respect to the date specified in the SeriesEndDate property, and sets the state of the series to “canceled”.

This allows you to preserve the instances of a recurring appointment series even if you have decided to end it prematurely. This is useful if you have attached notes or attachments to past instances of a recurring appointment series that contain important information about the customer or business.

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 a recurring appointment series
RecurringAppointmentMaster retrievedRecurringAppointmentSeries = (RecurringAppointmentMaster)_serviceProxy.Retrieve(RecurringAppointmentMaster.EntityLogicalName, _recurringAppointmentMasterId, new ColumnSet(true));

// Use the DeleteOpenInstances message to end the series to the
// last occurring past instance date w.r.t. the series end date
// (i.e., 20 days from today). Effectively, that means that the 
// series will end after the third instance (day 14) as this
// instance is the last occuring past instance w.r.t the specified 
// series end date (20 days from today).
// Also specify that the state of past instances (w.r.t. the series 
// end date) be set to 'completed'.
DeleteOpenInstancesRequest endAppointmentSeries = new DeleteOpenInstancesRequest
{
    Target = retrievedRecurringAppointmentSeries,
    SeriesEndDate = DateTime.Today.AddDays(20),
    StateOfPastInstances = (int)AppointmentState.Completed
};
_serviceProxy.Execute(endAppointmentSeries);

Console.WriteLine("The recurring appointment series has been ended after the third occurrence.");


' Retrieve a recurring appointment series
Dim retrievedRecurringAppointmentSeries As RecurringAppointmentMaster = _
    CType(_serviceProxy.Retrieve(RecurringAppointmentMaster.EntityLogicalName, _recurringAppointmentMasterId, _
                                 New ColumnSet(True)), RecurringAppointmentMaster)

' Use the DeleteOpenInstances message to end the series to the
' last occurring past instance date w.r.t. the series end date
' (i.e., 20 days from today). Effectively, that means that the 
' series will end after the third instance (day 14) as this
' instance is the last occuring past instance w.r.t the specified 
' series end date (20 days from today).
' Also specify that the state of past instances (w.r.t. the series 
' end date) be set to 'completed'.
Dim endAppointmentSeries As DeleteOpenInstancesRequest = New DeleteOpenInstancesRequest With { _
    .Target = retrievedRecurringAppointmentSeries, .SeriesEndDate = Date.Today.AddDays(20), _
    .StateOfPastInstances = CInt(Fix(AppointmentState.Completed))}
_serviceProxy.Execute(endAppointmentSeries)

Console.WriteLine("The recurring appointment series has been ended after the third occurrence.")

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.Crm.Sdk.Messages Namespace
Delete or end a recurring appointment series or instance
RecurringAppointmentMaster entity messages and methods
Sample: End a recurring appointment series

Return to top

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright