locked
How to create Custom Currencies by code (C#) on CRM 2011 RRS feed

  • Question

  • Hello,

    I'm trying to create some custom currencies with c#, but every time I call the "Create" it returns an error "Invalid ISO Currency Code." 
    Using the same data I can create the currency through the user interface by selecting the type "Custom" (see image), but I do not know how to specify the "Custom" via code.

    The purpose is to create the currencies to be used in single opportunity to bypass the standard mechanism who update the exchange rate and thus have a kind of "fixed rate" on opportunity

    Any Idea?

    Mauro Maniforti

    Saturday, October 4, 2014 9:31 AM

All replies

  • Hi Mauro,
    you got the error because when you create by code you are setting a currency code with more or less then 3 characters. currency code must be of 3 characters.

    Create custom currencies by code


    My blog: www.crmanswers.net - Rockstar 365 Profile

    Saturday, October 4, 2014 10:02 AM
  • Thank you Guido for your response

    Unfortunately I tried to do as you say with no success 
    I tried with isocurrencycode <3 = 3 and> 3 characters but the error message is always the same. 

    I also tried not to assign "isocurrencycode" or alternatively "CurrencyName" without success

    It seems that it does not recognize in any way the attempt to create a custom currency and always consider it as "System currency"

    This is an exmple of the code:

    Entity nc = new Entity("transactioncurrency");

    nc.Attributes.Add(new System.Collections.Generic.KeyValuePair<string, object>("currencyprecision", (int) 2)); nc.Attributes.Add(new System.Collections.Generic.KeyValuePair<string, object>("currencysymbol", "$")); nc.Attributes.Add(new System.Collections.Generic.KeyValuePair<string, object>("exchangerate", (decimal)1.2)); nc.Attributes.Add(new System.Collections.Generic.KeyValuePair<string, object>("isocurrencycode", "vv2")); nc.Attributes.Add(new System.Collections.Generic.KeyValuePair<string, object>("currencyname", "124")); service.Create(nc);


    Saturday, October 4, 2014 3:25 PM
  • digits are not allowed, only characters from a to z, for this vv2 is not created, vvv or vva or vvb are ok

    My blog: www.crmanswers.net - Rockstar 365 Profile


    Saturday, October 4, 2014 4:27 PM
  • Solved

    ISO Currency code must be 3 characters, not contain numbers or other (only characters A through Z) and be unique

    In this way, the CRM accept creation as custom currency

    Thank you Guido

    Sunday, October 5, 2014 9:43 AM