Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Tuesday, June 20, 2023

X++ code to get ExchRate() in D365

 hi,


  public ExchRate exchRate(

        CurrencyCode _fromCurrency,

        CurrencyCode _toCurrency = Ledger::find(Ledger::current()).AccountingCurrency,

        TransDate    _transDate = today(),

)

    {

        ExchangeRate     exchangeRate;

        ExchangeRateType ExchangeRateType;

        ExchangeRateCurrencyPair exchangeRateCurrencyPair;

        real             exchRate;


        CurrencyCode fromCurrency  = this.CurrencyCode;

        TransDate    transDate     = this.TransDate;


        select firstonly exchangeRateCurrencyPair   where

        exchangeRateCurrencyPair.ExchangeRateType == Ledger::find(Ledger::current()).DefaultExchangeRateType

        &&  exchangeRateCurrencyPair.FromCurrencyCode == _fromCurrency

        &&  exchangeRateCurrencyPair.ToCurrencyCode   == _toCurrency;

        return exchangeRate::findByDate(exchangeRateCurrencyPair.RecId,_transDate).ExchangeRate;

    }

How find size of recordsortedlist in D365/AX 2012

Hi, This is the continuity of the previous article where we are now getting the size of recordsortedlist . if(recordsortedlist.len() >1) ...