Partilhar via


DeleteOpenInstancesRequest Class

Definition

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

public ref class DeleteOpenInstancesRequest sealed : Microsoft::Xrm::Sdk::OrganizationRequest
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/crm/2011/Contracts")]
public sealed class DeleteOpenInstancesRequest : Microsoft.Xrm.Sdk.OrganizationRequest
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/crm/2011/Contracts")>]
type DeleteOpenInstancesRequest = class
    inherit OrganizationRequest
Public NotInheritable Class DeleteOpenInstancesRequest
Inherits OrganizationRequest
Inheritance
DeleteOpenInstancesRequest
Attributes

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 instance.

/// <summary>
/// Demonstrates the DeleteOpenInstances message
/// </summary>
/// <param name="service">The authenticated IOrganizationService instance.</param>
/// <param name="recurringAppointmentMasterId">The ID of the recurring appointment master record.</param>
static void DeleteOpenInstancesExample(IOrganizationService service,
      Guid recurringAppointmentMasterId)
{
      // Retrieve a recurring appointment series
      Entity retrievedRecurringAppointmentSeries = service.Retrieve(
         "recurringappointmentmaster",
         recurringAppointmentMasterId,
         new ColumnSet());

      // 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 request = new()
      {
         Target = retrievedRecurringAppointmentSeries,
         SeriesEndDate = DateTime.Today.AddDays(20),
         StateOfPastInstances = 1 // AppointmentState Completed
      };
      service.Execute(request);

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

Remarks

For the Web API use the DeleteOpenInstances action.

Usage

Pass an instance of this class to the Execute(OrganizationRequest) 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. The prvReadActivity and prvWriteActivity privileges are required.

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.

Constructors

DeleteOpenInstancesRequest()

Initializes a new instance of the DeleteOpenInstancesRequest class.

Properties

ExtensionData

Gets or sets the structure that contains extra data. Optional.

(Inherited from OrganizationRequest)
Item[String]

Gets or sets the indexer for the Parameters collection.

(Inherited from OrganizationRequest)
Parameters

Gets or sets the collection of parameters for the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
RequestId

Gets or sets the ID of the request. Optional.

(Inherited from OrganizationRequest)
RequestName

Gets or sets the name of the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
SeriesEndDate

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

StateOfPastInstances

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

Target

Gets or sets the target record for the operation. Required.

Applies to