แชร์ผ่าน


ConvertDateAndTimeBehaviorRequest Class

Definition

Contains the data to convert existing UTC date and time values in the database to DateOnly values.

public ref class ConvertDateAndTimeBehaviorRequest sealed : Microsoft::Xrm::Sdk::OrganizationRequest
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class ConvertDateAndTimeBehaviorRequest : Microsoft.Xrm.Sdk.OrganizationRequest
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")>]
type ConvertDateAndTimeBehaviorRequest = class
    inherit OrganizationRequest
Public NotInheritable Class ConvertDateAndTimeBehaviorRequest
Inherits OrganizationRequest
Inheritance
ConvertDateAndTimeBehaviorRequest
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 use of the ConvertDateAndTimeBehavior message
/// </summary>
/// <param name="service">Authenticated IOrganizationService instance</param>
static void ConvertDateAndTimeBehavior(IOrganizationService service)
{
      string tableLogicalName = "account";
      string columnLogicalName = "new_sampledatetimeattribute";


      ConvertDateAndTimeBehaviorRequest request = new()
      {
         Attributes = new EntityAttributeCollection()
         {
            new KeyValuePair<string, StringCollection>(tableLogicalName, new StringCollection()
            { columnLogicalName })
         },
         ConversionRule = DateTimeBehaviorConversionRule.SpecificTimeZone.Value,
         TimeZoneCode = 190, // Time zone code for India Standard Time (IST) in Dataverse
         AutoConvert = false // Conversion must be done using ConversionRule
      };

      // Execute the request
      var response = (ConvertDateAndTimeBehaviorResponse)service.Execute(request);

      Console.WriteLine($"Asynchronous Job ID: {response.JobId}");
}

Output:

Asynchronous Job ID: 41a32a2b-258c-4780-91bd-5a68a943009a

Remarks

Usage

Pass an instance of this class to the Execute(OrganizationRequest) method, which returns an instance of the ConvertDateAndTimeBehaviorResponse class.

Privileges and Access Rights

To perform this action, the caller must have the System Administrator role. For more information, see Convert behavior of existing date and time values in the database.

Constructors

ConvertDateAndTimeBehaviorRequest()

Initializes a new instance of the ConvertDateAndTimeBehaviorRequest class.

Properties

Attributes

Gets or sets a collection of entity and attributes to apply the behavior conversion on. Required

AutoConvert

Gets or sets whether to automatically convert to DateOnly value, if possible. Optional.

ConversionRule

Gets or sets the conversion rule to apply. Required.

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)
TimeZoneCode

Gets or sets the Dataverse time zone code to be used for the conversion. Required only if SpecificTimeZone is specified in ConversionRule parameter.

Applies to