none
String was not recognized as a valid DateTime

    Question

  • Hellos,

    I have a problem when i pick estimated close date and some custom entitys on crm.

    I got a error "String was not recognized as a valid DateTime"

    Any Help Thanks in advance.

    Microsoft CRM Error Report:

    Error Description:

    An unhandled exception occurred during the
    execution of the current web request. Please review the stack trace for more
    information about the error and where it originated in the
    code.


    Error Details:

    Exception of type 'System.Web.HttpUnhandledException' was thrown.

    Full
    Stack:
    [FormatException: String was not recognized as a valid DateTime.]
       at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
       at Microsoft.Crm.Application.Platform.AttributeCollection.CreateValueFromDateTimePropertyValue(String name, Object value)
       at Microsoft.Crm.Application.Platform.AttributeCollection.SetEntityProperty(Entity entity, String name, String childAttributeName, Object parentProperty, AttributeMetadata attributeMetadata, Object value, IOrganizationContext context)
       at Microsoft.Crm.Application.Platform.AttributeCollection.Insert(String name, Object value, Boolean throwIfKeyExists)
       at Microsoft.Crm.Application.Platform.EntityProxy.SetData(XmlNode entityElement)
       at Microsoft.Crm.Application.Forms.EndUserForm.RetrieveParametersForEventDefault()
       at Microsoft.Crm.Application.Forms.EndUserForm.Initialize(Entity entity)
       at Microsoft.Crm.Application.Forms.CustomizableForm.Execute(Entity entity, FormDescriptor fd)
       at Microsoft.Crm.Application.Components.PageHandlers.OpportunityRecordPageHandler.ConfigureFormHandler()
       at Microsoft.Crm.Application.Components.Utility.GenericEventProcessor.RaiseEvent(String eventName)
       at Microsoft.Crm.Application.Controls.PageManager.OnPreRender(EventArgs e)
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    [HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.]
       at System.Web.UI.Page.HandleError(Exception e)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       at System.Web.UI.Page.ProcessRequest()
       at System.Web.UI.Page.ProcessRequest(HttpContext context)
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

    Other Message:

    Error Number:

    Source File:
    Not available

    Line Number:
    Not available

    Error Trace:
    Date: 04-16-2012

    Time:
    17:20:26

    Server:
    gtaxvirtual
    Request URL:
    http://gtaxvirtual:5555/Cads/userdefined/edit.aspx?_gridType=3&etc=3&id=%7bA1E9FE1C-E783-E111-962D-00219B1AC5C2%7d&pagemode=iframe&preloadcache=1334618414338&rskey=253801211
    Monday, April 16, 2012 11:26 PM

Answers

All replies

  • Hi Juan,

    Try applying date and time functions on that variable. I mean try converting the value in the variable to a date and time.

    Remember CRM converts between UTC (on the database) and local time (adjusting for DST) for display on forms. When looking at the value of dates while debugging your code you need to know whether you are looking at a UTC or local DateTime to know whether it is 'correct'. You can find out by looking at the DateTime.Kind property.

    I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.


    Ashish Mahajan, CRM Developer, CSG (Melbourne)
    My Personal Website: http://www.ashishmahajan.com
    My Blogs: http://ashishmahajancrm.blogspot.com.au and http://ashishmahajancrm.wordpress.com
    My Youtube Channel: http://www.youtube.com/user/ashishmahajanmscrm

    My Linkedin: View Ashish Mahajan's profile on LinkedIn
    My Twitter: https://twitter.com/#!/ashishmahajan74

    Monday, April 16, 2012 11:32 PM
  • Hello Ashish,

    Did not work.

    Microsoft CRM Error Report:
    Error Description:
    An unhandled exception occurred during the
    execution of the current web request. Please review the stack trace for more
    information about the error and where it originated in the
    code.

    Error Details:
    Exception of type 'System.Web.HttpUnhandledException' was thrown.

    Full
    Stack:

    [FormatException: String was not recognized as a valid DateTime.]
       at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
       at Microsoft.Crm.Application.Platform.AttributeCollection.CreateValueFromDateTimePropertyValue(String name, Object value)
       at Microsoft.Crm.Application.Platform.AttributeCollection.SetEntityProperty(Entity entity, String name, String childAttributeName, Object parentProperty, AttributeMetadata attributeMetadata, Object value, IOrganizationContext context)
       at Microsoft.Crm.Application.Platform.AttributeCollection.Insert(String name, Object value, Boolean throwIfKeyExists)
       at Microsoft.Crm.Application.Platform.EntityProxy.SetData(XmlNode entityElement)
       at Microsoft.Crm.Application.Forms.EndUserForm.RetrieveParametersForEventDefault()
       at Microsoft.Crm.Application.Forms.EndUserForm.Initialize(Entity entity)
       at Microsoft.Crm.Application.Forms.CustomizableForm.Execute(Entity entity, FormDescriptor fd)
       at Microsoft.Crm.Application.Components.PageHandlers.OpportunityRecordPageHandler.ConfigureFormHandler()
       at Microsoft.Crm.Application.Components.Utility.GenericEventProcessor.RaiseEvent(String eventName)
       at Microsoft.Crm.Application.Controls.PageManager.OnPreRender(EventArgs e)
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    [HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.]
       at System.Web.UI.Page.HandleError(Exception e)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       at System.Web.UI.Page.ProcessRequest()
       at System.Web.UI.Page.ProcessRequest(HttpContext context)
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

    Other Message:


    Error Number:

    Source File:
    Not available

    Line Number:
    Not available

    Error Trace:
    Date: 04-16-2012

    Time:
    17:40:21

    Server:
    gtaxvirtual
    Request URL:
    http://gtaxvirtual:5555/Cads/userdefined/edit.aspx?_gridType=3&etc=3&id=%7bA2D27C0A-2484-E111-A27B-00219B1AC5C2%7d&pagemode=iframe&preloadcache=1334619606761&rskey=326820393
    Monday, April 16, 2012 11:41 PM
  • The solution is just to change the name to function in jscript since was the same as using crm :S.

    Thanks for the help.

    • Marked as answer by Juan Solares Friday, May 04, 2012 5:16 PM
    Friday, May 04, 2012 5:16 PM