Do you know how to get the exchange rate in Dynamics AX2012 ?

Today I was faced with the challenge of extracting the Exchange Rate in AX 2012 for a Purchase Order, and I found a solution that I think will be useful for many of you. Here’s how it’s done:

First we should declare some variables, please take into account that we will do this into a Job so this variables are recommended to be on the class declaration if you’re using them on a method of a class:

imagen1

As we can see we will use the ExchangeRateHelper class, a transDate variable for our date, the currency code that we are initializing as EUR  (Euros), and two currency exchange rate variables.

Now that we have our variables we will set the date we want the currency exchange, for this example we will use today’s date:

imagen2

Now we will initialize our Helper class using the sintax below:

imagen3

This will use the data we set before, those are the type of ledger, the transaction currency and the date.

Next we will use our CurrencyExchangeRate variables to store the result of the method getExchangeRate1

And getExchangeRate2:

imagen4

Finally we will output the results into an info dialog, but because we’re outputting a number we will use also the num2str method that will output our number into a string. Also take into account that we are dividing the result by 100 to get the real exchange rate:

imagen5

And as we can see the exchange rate configured on AX is shown:

imagen6

So just to be sure let’s check on the exchange type form of AX:

imagen7

And as expected we got the same result.

  • Andesoft International

    by LP