Skip to main content

Posts

Showing posts from December, 2019

Importing Exchange Rate in D365 F&O AX 2012 using X++ code

Exchange rate is one of the common factor used in D365 F&O used usually when conversion in between Accounting currency-Reporting currency or transnational currency-Accounting currency is required. Purpose of this code is to retrieve current conversion rate configured in our AX for a particular date. public CurrencyExchangeRate CMTExchangeRateCalculator( TransDate transDate,VendCurrencyCode fromCurrency,VendCurrencyCode toCurrency)     {         ExchangeRateType ExchangeRateType;         ExchangeRateCurrencyPair exchangeRateCurrencyPair;         real             exchRate;            if(fromCurrency != toCurrency)         {             select firstonly exchangeRateCurrencyPair             where                 exchangeRateCurrencyPair.ExchangeRateType ==               Ledger::find(Ledger::current()).DefaultExchangeRateType                 &&  exchangeRateCurrencyPair.FromCurrencyCode == fromCurrency                 &&  exchangeRateCurrencyP

Email Validation Function in D365 using X++

Validation of email is one of the feature that has been most commonly used in Dynamics AX. We being a developer many times came across with the requirements that needs email validation so i have written a function that uses regex regular expression to validate emails. Retirements: 1)We need to declare a const str in the class that will contain all characters, public const Str MatchEmailPattern =        @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"      + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?        [0-9]{1,2}|25[0-5]|2[0-4][0-9])\."      + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?        [0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"      + @"([\w-]+\.)+[a-zA-Z]{2,4})$"; 2) The above, MatchEmailPattern will be called within the function "validateEmail" that will return boolean //function "validateEmail"  private boolean validateEmail(Email _email)     {         boolean   ret = true;         Boo