web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Get currency exchange rate by specific date by X++

(0) ShareShare
ReportReport
Posted on by 46

Hi all,

I am working on customizing the Cost Estimates and Costings Report by retrieving the result from the Sales Line Price minus(-) the cost of production.

I already have the sales price that is linked to the production (TransRefId/CollectRefProdId). The problem comes when the Currecy from the sales is different from the company we are working with.

so pulling out the currency by X++ at the moment the sales was made is the only option I can think of.

I have just coppied a code from this community https://community.dynamics.com/ax/b/hellodax/posts/get-currency-exchange-rate-using-ax-class

but is not working well all the time, as you can see in pictures is taking correctly the currecny from EUR to any other currency but is not taking for example PLN to DKK .

Thanks a lot for your time, your help is greatly appreciated

pastedimage1598335157699v1.pngpastedimage1598335197231v2.pngpastedimage1598335231114v3.png

pastedimage1598335573409v4.png

I have the same question (0)
  • WillWU Profile Picture
    22,361 on at

    Hi Nestor,

    Have you tried the findByDate() method on the table ExchangeRate?

    community.dynamics.com/.../how-to-get-exchange-rate-in-x

  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi CBNestor,

    I would change the final info message to get currency codes from ExchangeRateHelper.parmFromCurrency and ExchangeRateHelper.parmToCurrency, to be sure that values were passed correctly to ExchangeRateHelper class.

  • CBNestor Profile Picture
    46 on at

    Hi Sergei,

    Looks like is taking the parameters correctly

    pastedimage1598340328373v1.png

  • CBNestor Profile Picture
    46 on at

    Hi Will,

    Thanks for fast reply. I will take a look to the code and see if works

  • CBNestor Profile Picture
    46 on at

    Will I tested the Code. I can see is looping directly to the table

    Is not making the right triangulation between EUR and other. that means I have EUR-PLN and EUR-DKK it wont bring  any result when asking for PLN-DKK.

    that means if I delete the PLN to DKK from the ExchageRatePair table it wont give me any currency even though the sales transaction was made long time ago when this rate in fact did exist

    pastedimage1598342250215v2.png

  • WillWU Profile Picture
    22,361 on at

    Hi Nestor,

    Please check the exchangeRateCurrencyPair table, does it have a record links PLN and DKK?

  • CBNestor Profile Picture
    46 on at

    Hi Will thanks for replay

    I am plannig to Let the AX update the currency rate from the EU Bank actual currency rate. So the PLN-DKK should not exist. thats why this code wont work so well for me in the future.

  • Suggested answer
    CBNestor Profile Picture
    46 on at

    Finally Resarching a bit

    A found a solution which is supplied and well explained by Microsoft in this Paper = Shared Currencies and Exchange Rates for Microsoft Dynamics AX 2012

    They explain the necessary codes needed on each situation, like mine, here a pic of the code to get the currency between two currencies , ExchangeRate1 and ExchangeRate2 are griven. Also the Euro triangulation is always taken in consideration, also works for any combination outside the euro triangulation.

    someone please set this as Solved.

    thanks a lot for your time, appreciated.

    pastedimage1599124769488v1.png

    pastedimage1599124817489v2.pngpastedimage1599124864340v3.png

    pastedimage1599124951237v4.png

  • WillWU Profile Picture
    22,361 on at

    Hi Nestor,

    Thanks for your sharing!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans