Thursday, April 30, 2026

Get all Dimensions values with - separated with provided dimension recid

 To get all dimension with - separated with provided dimension recid

Code:-

public static str Getdimensionset(RecId recid)
{
     str                                 descriptionLedgerLoc = '';
     boolean                             first = true;
     DimensionAttributeLevelValueAllView view,viewloc;
     DimensionAttributeValue             dimValue;
     DimensionAttributeValueGroup        dimensionAttributeValueGroup;
     container                           con;

     select firstonly viewloc
         where viewloc.ValueCombinationRecId==recid;

 

     while select view order by view.ValueOrdinal asc
      where view.ValueCombinationRecId == recid
&& view.DimensionAttributeValueGroup==viewloc.DimensionAttributeValueGroup
     {

         if (!first)
         {
             descriptionLedgerLoc += " - ";
         }
         descriptionLedgerLoc +=view.DisplayValue ;
         first = false;


     }
     return descriptionLedgerLoc;
}


Note:-dimensions will get with - separated

Thank you!!

Get dimensions values with provided dimension Recid

 To get Dimensions value as displayed in Control level 

Code:-

LedgerDimensionFacade::getDisplayValueForLedgerDimension(DimensionRecid);

Note:- dimensions will get with ~ separated

Thank you!!

Thursday, April 23, 2026

Run a class through front end in d365fo

 link to run a class from front end through sysclassrunner

dynamics url/?mi=SysClassRunner&cls=classname

Get amount with required exchange rate of currency

Scenario:- When you need to get amount with required exchange rate.

Case :- It also depends on whether we are going with Account currency exchange rate or Budget exchange rate type as shown in image below 

Case 1:- If it is Budget exchange

Code:-

CurrencyCode            currencyCode = SystemParameters::find().SystemCurrencyCode;
            str fromcurrency='USD';
            str tocurrency='CAD';
            real amount=120;
            CurrencyExchangeHelper  currencyExchangeHelper;
            currencyExchangeHelper = currencyExchangeHelper::construct();
            currencyExchangeHelper.parmLedgerRecId(Ledger::current());
            currencyExchangeHelper.parmExchangeRateTypeRecId(Ledger::budgetExchangeRateType());
            Info(strFmt("%1",currencyExchangeHelper.calculateCurrencyToCurrency(fromcurrency, tocurrency,amount, true)));

Case 2:- If it is Account currency exchange rate

Code:-

CurrencyCode            currencyCode = SystemParameters::find().SystemCurrencyCode;
            str fromcurrency='USD';
            str tocurrency='CAD';
            real amount=120;
            CurrencyExchangeHelper  currencyExchangeHelper;
            currencyExchangeHelper = currencyExchangeHelper::construct();
            currencyExchangeHelper.parmLedgerRecId(Ledger::current());
            currencyExchangeHelper.parmExchangeRateTypeRecId(Ledger::defaultExchangeRateType());
            Info(strFmt("%1",currencyExchangeHelper.calculateCurrencyToCurrency(fromcurrency, tocurrency,amount, true)));


Monday, April 20, 2026

Stop sending notifications from dynamics through SMTP when you have subject #FAIL#

Scenario :- I got a requirement where dynamics sends notification and these notifications are to be restricted so these the logic where you can control the notifications.

Code:-

ExtensionOf(classstr(SysMailerSMTP))]
 final class NotificationsstopSysMailerSMTP_Extension
{

    protected boolean sendMessage(System.Net.Mail.MailMessage _message, boolean _interactive, guid _correlationId)
    {
        str val="#FAIL#";
        if(strKeep(val,_message.Subject)==val)
        {
            System.Net.Mail.MailAddress buf;
            System.Net.Mail.MailAddressCollection buf2;
            System.Net.Mail.MailMessage _messageloc;
            _message=_messageloc;
            _message.Subject='';
            _message.Sender=buf;
        }
        boolean ret;
       
        ret =  next sendMessage( _message,  _interactive,  _correlationId);
        return ret;
       
    }

}

NOTE:- This is a framework class customizations .So make sure we go with procedure  until and unless you are confident to implement the change

Thank you !! 

Thursday, April 16, 2026

How to make a workflow global or legal entity specific

 scenario :- Generally in Dynamics there are some workflows with globally and some are Legal entity specific . With association type  as shown in below

Step 1:- To make a workflow global or Legal entity specific. Go to visual studio >

find the workflow type and click on properties and in  Association type choose the type you need as shown in below

Note :- Don't change this for standard workflows. And can use this for Custom mostly.

Wednesday, April 15, 2026

DB restore from tier 2 to tier 1

 Step 1:- Get Backpac file to your dev machine

Step2:- move this file to location as shown in below

                                     

Step 2 :- Navigate to Download and Install SqlPackage - SQL Server | Microsoft Learn 

and scroll down for windows package as shown in below

download the file and extract the zip file

Step 3:- open the file and copy location as shown in below


Step 4:-Open commnd promt with run of administrator and run cd paste the location copied from above as shown in below

Step5:-run this command SqlPackage.exe /a:import /sf:J:\MSSQL_BACKUP\uatbackup.bacpac /tsn:localhost /tdn:AXDB_New /TargetTrustServerCertificate:True  /p:CommandTimeout=1500


Step 6:-Wait for 6 hours until you see DB restored sucessfully.

Step 7:-Go to SSMS >Database >AXDB>properites>makes multiuser to single user 

then Rename to AXDB_OLD 

Step 8:-Rename AXDB_New (new db restored) to AXDB 

Make AXDB_OLD  properties to single user

Step 9:-Restart all services. Now Dev machines runs with Tier 2 database 

Note:- This process is when you have been given with bacpac file (usually when we export tier 2 it will be bacpac only.most of the time we get bacpac file only).

If we get bac file we can directly restore with in few steps and lesstime in ssms itself without cmd promt.


Thank you!!





Get all Dimensions values with - separated with provided dimension recid

 To get all dimension with - separated with provided dimension recid Code:- public static str Getdimensionset(RecId recid) {      str     ...