0

I have Field in DateTime type and I want to set it's value in images in Plugins set the value in Pre image and after update set the updated value in Post image.

The mother form field type DateTime and the child form contains 2 fields (old value field type Text string and the second field new value Type Text string )

if (customerDataPreImage.Contains("ph_releasedate"))
{
     customerHistory["ph_oldreleasedate"] = Convert.ToDateTime(customerDataPreImage.Attributes["ph_releasedate"]);
}
if (customerDataPostImage.Contains("ph_releasedate"))
{
     customerHistory["ph_newreleasedate"] = Convert.ToDateTime(customerDataPostImage.Attributes["ph_releasedate"]);
}
KJSR
  • 1,679
  • 6
  • 28
  • 51
Tony Medhat
  • 47
  • 1
  • 8
  • An error occurred in the Plugin.System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Incorrect type of attribute value System.DateTime (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault) – Tony Medhat Sep 11 '19 at 08:30

1 Answers1

0

after change field type to datetime and use this code working fine now

if (customerDataPreImage.Contains("ph_releasedate")) {
    customerHistory["ph_oldreleasedate2"] = customerDataPreImage.Attributes["ph_releasedate"];
}
if (customerDataPostImage.Contains("ph_releasedate")) {
    customerHistory["ph_newreleasedate2"] = customerDataPostImage.Attributes["ph_releasedate"];
}
Ryan James
  • 196
  • 1
  • 8
Tony Medhat
  • 47
  • 1
  • 8