Search code examples
c#pluginsdynamics-crmmicrosoft-dynamicsdynamics-365

Unable to cast object of type 'Microsoft.Xrm.Sdk.Money' to type 'System.IConvertible'.Detail:


I'm getting this error when I try converting from Money data to decimal in my CRM plugin project. Please how can I solve this error.

Here is my code below -
Sample Code

1.

This is a sample of the error output - Sample Error Message

2


Solution

  • You can't just convert anything into a decimal.

    However, the Microsoft.Xrm.Sdk.Money class has a Value property you can use to get the decimal amount:

    var membershipFee = membershipType.senior_applocationFee.Value;