Monday, May 11, 2026

Assign roles through ssms in d365fo

 Step1;- Here my Role name I want to assign is System admin

SELECT  RecId,* FROM SecurityRole WHERE Name = 'System administrator';

step 2:- User name here is sai  and pass recid from above to below query

insert into SECURITYUSERROLE (USER_, SECURITYROLE, ASSIGNMENTSTATUS, ASSIGNMENTMODE)
VALUES ('sai', 171,1,1);


Thats it!! refresh and check


For deleting of roles through SSMS

Step1:-SELECT  RecId,* FROM SecurityRole WHERE Name = 'System administrator';

pass recid from above to below query

Step 2:-DELETE FROM SECURITYUSERROLE WHERE USER_='sai'and SECURITYROLE=171;


Thank you!!

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.

Assign roles through ssms in d365fo

 Step1;- Here my Role name I want to assign is System admin SELECT  RecId,* FROM SecurityRole WHERE Name = 'System administrator'; s...