locked
DateTime is less than minumum value supported by CrmDateTime. Actual value: 01/02/0001 00:00:00, Minimum value supported: 01/01/1900 00:00:00 RRS feed

  • Question

  • Hi,

    I am trying to do the bulk delete inside a plugin and getting errors.  If I use the same code from Console app, it works.

     var conditionDate = DateTime.Now.AddDays(-1);
                //localPluginContext.Trace(conditionDate.ToString("YYYY"));
                // Create a condition for a bulk delete request.
                // NOTE: If no records are found that match this condition, the bulk delete
                // will not fail.  It will succeed with 0 successes and 0 failures.
                var deleteCondition = new ConditionExpression("createdon", ConditionOperator.LessThan, DateTime.Now);

                // Create a fiter expression for the bulk delete request.
                var deleteFilter = new FilterExpression();
                deleteFilter.Conditions.Add(deleteCondition);

                // Create the bulk delete query set.
                var bulkDeleteQuery = new QueryExpression
                {
                    EntityName = "gw_plugintracelog",
                    Distinct = false,
                    Criteria = deleteFilter                
                };
                localPluginContext.Trace(localPluginContext.PluginExecutionContext.UserId.ToString());
                // Create the bulk delete request.
                var bulkDeleteRequest = new BulkDeleteRequest
                {
                    JobName = "Plugin Trace Bulk Delete",
                    QuerySet = new[] { bulkDeleteQuery },
                    StartDateTime = DateTime.Now,
                    ToRecipients = new[] { localPluginContext.PluginExecutionContext.UserId },
                    CCRecipients = new Guid[] { },
                    SendEmailNotification = false,
                    RecurrencePattern = String.Empty,

                };
                localPluginContext.Trace("Launch the bulk delete");
                var response = localPluginContext.OrganizationService.Execute(bulkDeleteRequest);
                if (response == null)
                    throw new ApplicationException("Bulk delete can not be started");

    Stacktrace:

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Scheduled Process Plugin Failed to RunDetail: 
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
      <ErrorCode>-2147220891</ErrorCode>
      <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
        <KeyValuePairOfstringanyType>
          <d2p1:key>OperationStatus</d2p1:key>
          <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">0</d2p1:value>
        </KeyValuePairOfstringanyType>
        <KeyValuePairOfstringanyType>
          <d2p1:key>SubErrorCode</d2p1:key>
          <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">-2146233088</d2p1:value>
        </KeyValuePairOfstringanyType>
      </ErrorDetails>
      <Message>Scheduled Process Plugin Failed to Run</Message>
      <Timestamp>2014-08-27T12:06:37.5631165Z</Timestamp>
      <InnerFault i:nil="true" />
      <TraceText>

    [GW.CRMPlugins.ScheduledProcesses: GW.CRMPlugins.ScheduledProcesses.ScheduledProcessPlugin]
    [1d8c5653-6129-e411-8b87-0050569e310d: GW.CRMPlugins.ScheduledProcesses.ScheduledProcessPlugin: Update of gw_scheduledprocess]

    Launching PluginMessagesCleanup , Correlation Id: 079c3e35-8a07-4e6f-af77-fac1e4fab462, Initiating User: 7603e114-e71b-e411-8a3e-0050569e310d
    7603e114-e71b-e411-8a3e-0050569e310d, Correlation Id: 079c3e35-8a07-4e6f-af77-fac1e4fab462, Initiating User: 7603e114-e71b-e411-8a3e-0050569e310d
    Launch the bulk delete, Correlation Id: 079c3e35-8a07-4e6f-af77-fac1e4fab462, Initiating User: 7603e114-e71b-e411-8a3e-0050569e310d
    Exception: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: DateTime is less than minumum value supported by CrmDateTime. Actual value: 01/02/0001 00:00:00, Minimum value supported: 01/01/1900 00:00:00 (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault)., Correlation Id: 079c3e35-8a07-4e6f-af77-fac1e4fab462, Initiating User: 7603e114-e71b-e411-8a3e-0050569e310d
    Exception: 
    Server stack trace: 
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc&amp; rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]: 
       at Microsoft.Crm.Sandbox.SandboxOrganizationService.Execute(String operation, Byte[] serializedRequest)
       at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]&amp; outArgs)
       at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

    Exception rethrown at [1]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)
       at Microsoft.Crm.Sandbox.ISandboxOrganizationService.Execute(String operation, Byte[] serializedRequest)
       at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.ExecuteInternal(OrganizationRequest request)
       at GW.CRMPlugins.ScheduledProcesses.ScheduledProcessPlugin.Execute(IServiceProvider serviceProvider), Correlation Id: 079c3e35-8a07-4e6f-af77-fac1e4fab462, Initiating User: 7603e114-e71b-e411-8a3e-0050569e310d
    Entered .Execute(), Correlation Id: 079c3e35-8a07-4e6f-af77-fac1e4fab462, Initiating User: 7603e114-e71b-e411-8a3e-0050569e310d
     is firing for Entity: gw_scheduledprocess, Message: Update, Correlation Id: 079c3e35-8a07-4e6f-af77-fac1e4fab462, Initiating User: 7603e114-e71b-e411-8a3e-0050569e310d
    DateTime is less than minumum value supported by CrmDateTime. Actual value: 01/02/0001 00:00:00, Minimum value supported: 01/01/1900 00:00:00, Correlation Id: 079c3e35-8a07-4e6f-af77-fac1e4fab462, Initiating User: 7603e114-e71b-e411-8a3e-0050569e310d

    Server stack trace: 
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc&amp; rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]: 
       at Microsoft.Crm.Sandbox.SandboxOrganizationService.Execute(String operation, Byte[] serializedRequest)
       at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]&amp; outArgs)
       at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

    Exception rethrown at [1]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)
       at Microsoft.Crm.Sandbox.ISandboxOrganizationService.Execute(String operation, Byte[] serializedRequest)
       at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.ExecuteInternal(OrganizationRequest request)
       at GW.CRMPlugins.ScheduledProcesses.ScheduledProcessPlugin.Execute(IServiceProvider serviceProvider), Correlation Id: 079c3e35-8a07-4e6f-af77-fac1e4fab462, Initiating User: 7603e114-e71b-e411-8a3e-0050569e310d
    Create Error, Correlation Id: 079c3e35-8a07-4e6f-af77-fac1e4fab462, Initiating User: 7603e114-e71b-e411-8a3e-0050569e310d
    Exiting .Execute(), Correlation Id: 079c3e35-8a07-4e6f-af77-fac1e4fab462, Initiating User: 7603e114-e71b-e411-8a3e-0050569e310d


    </TraceText>
    </OrganizationServiceFault>

    Wednesday, August 27, 2014 12:13 PM

All replies

  • the error just says that the date value is null, I am not able to find the field name from the exception. Please check all the date fields and set the value correctly.

    regards.

    Jithesh

    Wednesday, August 27, 2014 2:02 PM
  • You may be getting locking issues, which ends up with an incorrect error message. I'd try registering the plugin to run asynchronously, to see if that makes a difference

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Wednesday, August 27, 2014 4:07 PM
    Moderator