Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Get currency exchange rate by specific date by X++

(0) ShareShare
ReportReport
Posted on by 44

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

  • WillWU Profile Picture
    WillWU 22,352 on at
    RE: Get currency exchange rate by specific date by X++

    Hi Nestor,

    Thanks for your sharing!

  • Suggested answer
    CBNestor Profile Picture
    CBNestor 44 on at
    RE: Get currency exchange rate by specific date by X++

    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

  • CBNestor Profile Picture
    CBNestor 44 on at
    RE: Get currency exchange rate by specific date by X++

    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.

  • WillWU Profile Picture
    WillWU 22,352 on at
    RE: Get currency exchange rate by specific date by X++

    Hi Nestor,

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

  • CBNestor Profile Picture
    CBNestor 44 on at
    RE: Get currency exchange rate by specific date by X++

    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

  • CBNestor Profile Picture
    CBNestor 44 on at
    RE: Get currency exchange rate by specific date by X++

    Hi Will,

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

  • CBNestor Profile Picture
    CBNestor 44 on at
    RE: Get currency exchange rate by specific date by X++

    Hi Sergei,

    Looks like is taking the parameters correctly

    pastedimage1598340328373v1.png

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Get currency exchange rate by specific date by X++

    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.

  • WillWU Profile Picture
    WillWU 22,352 on at
    RE: Get currency exchange rate by specific date by X++

    Hi Nestor,

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

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

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,684 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,414 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans