CRM 2011 – Dialog Date and Time Response type error

I was creating a dialog today and came up  against a very odd and annoying error.  I talk about it in this Hosk CRM Dev video or you can read the blog below.

I was trying to get an response of type Data and Time.  I thought I would be clever and default the time to the current time by using the Process –> Execution time.

Below you can see the values I have used

Dialog enddate error 1

but then when I tried to run the dialog and got this error

Dialog enddate error 2

and below you can see the error which was being thrown


</pre>
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Expected parameter of type System.DateTimeDetail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ErrorCode>-2147220989</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>Expected parameter of type System.DateTime</Message>
<Timestamp>2014-04-25T20:45:49.868266Z</Timestamp>
<InnerFault>
<ErrorCode>-2147220970</ErrorCode>
<ErrorDetails xmlns:d3p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>Unhandled Exception: Microsoft.Crm.CrmArgumentException: Expected parameter of type System.DateTime
at Microsoft.Crm.Workflow.Services.ExpressionServiceBase.EnsureParameterType(Object parameter, Type type)
at Microsoft.Crm.Workflow.Services.ExpressionServiceBase.EvaluateExpression(ExpressionOperator expressionOperator, Object[] parameters, Type targetType)
at Microsoft.Crm.Workflow.Activities.EvaluateExpression.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
Inner Exception: System.ArgumentException: Expected parameter of type System.DateTime

</Message>
<Timestamp>2014-04-25T20:45:49.868266Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText i:nil="true" />
</InnerFault>
<TraceText i:nil="true" />
</OrganizationServiceFault>

I couldn’t understand why it was throwing an error.  Logically it didn’t seem to make sense and the error message.

So I thought perhaps if I added one minute to the time this would then work and hey presto it did as you can see below
Dialog enddate error 3

 

So the moral of this story is, if something doesn’t work add a minute to it and who knows why that works

 

Advertisement