October 4, 2014

Create custom currencies by code

Dynamics CRM allows to create custom currencies in addition to the standard ones provided by the system.

The entity involved is transactioncurrency and the follow attributes are required to create a new currency:
  • currencyname (string)
  • currencyprecision (int)
  • currencysymbol (string)
  • exchangerate (decimal)
  • isocurrencycode (string)
The attribute isocurrencycode requires an additional check, it must contains always three letters, digits and special characters are not allowed.

Example:
Entity newCurrency = new Entity("transactioncurrency");

newCurrency["currencyname"] = "My Currency";
newCurrency["currencyprecision"] = 2;
newCurrency["currencysymbol"] = "@";
newCurrency["exchangerate"] = 2m;
newCurrency["isocurrencycode"] = "MCU"; // 3 letters

Guid newCurrencyId = service.Create(newCurrency);

0 comments:

Post a Comment