Greetings,
In a CRM 2013 on-premise plug-in post operation step when I am trying to update a DateTime field in an opportunity record after the opportunity has been closed as Lost for status, an exception of "Invalid cast operation" is thrown no matter what DateTime value format is assigned to the field:
Examples:
entity.Attributes["DateKilled"] = entity.GetAttributesValue<DateTime>("DateClosed"); // DateKilled is blank
or
entity.Attributes["DateKilled"] = entity.GetAttributesValue<DateTime>("DateClosed").ToShortDateString(); // DateClosed is populated
or
entity.Attributes["DateKilled"] = new DateTime(2016, 09, 15);
The exception is thrown no matter what format or type is assigned.
Is there a different way to update date type fields in CRM?
Thanks in advance for any help or suggestions.