Updating DateTime Field In Event Receiver sometimes give error, if we use:
properties.AfterProperties["ApprovedTimeStamp"] = DateTime.Now.ToString(); ;
properties.AfterProperties["ApprovedTimeStamp"] = DateTime.Now.ToShortDateString();
Above statements give error as,
Invalid date/time value. A date/time field contains invalid data. Please check thevalue and try again.
This issue is because, SharePoint date-time field accept values in predefined format.
To overcome this issue, try:
properties.AfterProperties["DueDate"] =
DateTime.Now.ToString("yyyy-MM-ddThh:mm:ssZ");
properties.AfterProperties["ApprovedTimeStamp"] = DateTime.Now.ToString(); ;
properties.AfterProperties["ApprovedTimeStamp"] = DateTime.Now.ToShortDateString();
Above statements give error as,
Invalid date/time value. A date/time field contains invalid data. Please check thevalue and try again.
This issue is because, SharePoint date-time field accept values in predefined format.
To overcome this issue, try:
properties.AfterProperties["DueDate"] =
DateTime.Now.ToString("yyyy-MM-ddThh:mm:ssZ");
No comments:
Post a Comment