kuhi
kuhi

Reputation: 699

How to currency exchange in Business Central with AL?

I'm trying to convert from currency A to currency B in Business Central.

This is the code I'm using, which throws the error "there is no currency exchange within the specified filter":

AmountInUSD := "Currency Exchange Rate".ExchangeAmount(1, 'EUR', 'USD', Rec.SetupDate);

Checking table 330 I see some conversion rates but I don't know how to exchange...

enter image description here

How can I exchange from currency A to currency B? Even if none of them is the LCY (local currency)? For example convert from EUR to USD and from USD to CAD.

Upvotes: 0

Views: 636

Answers (1)

kaspermoerch
kaspermoerch

Reputation: 16560

The function you are using should be okay for doing the conversion.

When exchanging between two foreign currencies the conversion is a two-step process:

  1. Convert from currency A to local currency (LCY).
  2. Convert from local currency (LCY) to currency B.

This means that there must be valid exchange rates for both the foreign currencies in order for the process to succeed.

Based on the provided information it looks like you are at least missing an exchange rate for EUR (USD is not shown on the image).

You need to go to the Currencies page and find the Exchange Rates action for each of the currencies in question and then create a new exchange rate.

Alternatively you can set up an Exchange Rate Service to allow for automatic updates of exchange rates.

Upvotes: 0

Related Questions