Search code examples
c#dynamics-crmcrm

Calculations with different datatypes in CRM


I am making some CRM plug-in using C#.

I have variable a containing Whole Number(Format: None), that should represent discount percent, it is limited from 0 to 100.

There is variable b that is Currency and represents Price.

I should count Final Price as Price - Discount, and put the result in variable c, that is also Currency

Is it possible to do

c = b*(100-a)/100;

Or there is some conversion to do?


Solution

  • Strictly speaking for Dynamics CRM with a generic calculation, the only thing you need to take care is accessing the right value from your input variable.

    In your case the b variable is a currency, meaning that probably is a Money type, so you will get the value from the Value property that is a decimal type.