Wierd one here. I've got a member record with a DOB field set to Date Picker type. Using the following code to add the record to the member (new member created)
// do all the other property updates here as well....
DateTime dob;
if (DateTime.TryParse('13/10/1950', out dob)) // also happens with dates like 05/10/1947
props.First(p => p.PropertyType.Alias == "dOB").Value = XmlConvert.ToString(dob, XmlDateTimeSerializationMode.RoundtripKind);
newMember.Save(); // <-- exception thrown here as below
Problem is we are getting exceptions when saving the member:
Error adding member with email address :[email protected], error displayed: System.InvalidCastException: Specified cast is not valid. at umbraco.editorControls.datepicker.DateData.ToXMl(XmlDocument d) at umbraco.cms.businesslogic.property.Property.ToXml(XmlDocument xd) at umbraco.cms.businesslogic.Content.XmlPopulate(XmlDocument xd, XmlNode& x, Boolean Deep) at umbraco.cms.businesslogic.member.Member.generateXmlWithoutSaving(XmlDocument xd) at umbraco.cms.businesslogic.member.Member.XmlGenerate(XmlDocument xd) at umbraco.cms.businesslogic.member.Member.Save() at SimonAntony.ImportModuleDT.UploadMembers(IList`1 import, Int32 SiteHomepageID, List`1 nodesList, Int32 ClubID)
Any ideas what could be wrong here - surely if the DateTime object can parse the input value, the xml converted string should be valid for Umbraco?
Not sure m8, basically the code has worked fine for a while then suddenly started to throw exceptions and unsure as to why. Now I cannot get it to work at all so we've had to remove it temporarily - wierd one for sure but i'll give it a shot
Saving date values via api problems
Hi
Wierd one here. I've got a member record with a DOB field set to Date Picker type. Using the following code to add the record to the member (new member created)
Problem is we are getting exceptions when saving the member:
Error adding member with email address :[email protected], error displayed: System.InvalidCastException: Specified cast is not valid. at umbraco.editorControls.datepicker.DateData.ToXMl(XmlDocument d) at umbraco.cms.businesslogic.property.Property.ToXml(XmlDocument xd) at umbraco.cms.businesslogic.Content.XmlPopulate(XmlDocument xd, XmlNode& x, Boolean Deep) at umbraco.cms.businesslogic.member.Member.generateXmlWithoutSaving(XmlDocument xd) at umbraco.cms.businesslogic.member.Member.XmlGenerate(XmlDocument xd) at umbraco.cms.businesslogic.member.Member.Save() at SimonAntony.ImportModuleDT.UploadMembers(IList`1 import, Int32 SiteHomepageID, List`1 nodesList, Int32 ClubID)
Any ideas what could be wrong here - surely if the DateTime object can parse the input value, the xml converted string should be valid for Umbraco?
Short in the dark here Simon, but would .Value.ToString() = XmlConvert.... work?
Not sure m8, basically the code has worked fine for a while then suddenly started to throw exceptions and unsure as to why. Now I cannot get it to work at all so we've had to remove it temporarily - wierd one for sure but i'll give it a shot
is working on a reply...