Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Updating a date field in Post Update plug-in step throws invalid cast operation

$
0
0

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.


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>