Sunday, February 15, 2026

Send mail Through SMTP with Template

 In this blog we see how to send mail through SMTP by using template 

Step 1:-

  Code :-

  Map           templateTokens;

  templateTokens = new Map(Types::String, Types::String);     

   SysMailerSMTP           mailer = new SysMailerSMTP();

        try

        {

            switch (workflowContext.parmTableId())

            {

                case tablenum(LedgerJournaltable) :

                    SysMailerMessageBuilder builder = new SysMailerMessageBuilder(); 

                

                    SysEmailParameters      parameters = SysEmailParameters::find();

 

                    SysEmailMessageSystemTable  messageTable;

                    str envUrl = URLUtility::getUrl();

                    select messageTable

            where messageTable.EmailId == "Template name";


              

                    templateTokens.insert("envUrl",envUrl);

                    templateTokens.insert("Ledger journal table.JournalName",strFmt("%1",ledgerJournaltable.JournalName));  


                    if (parameters.SMTPRelayServerName)

                    {

                        mailer.smtpRelayServer(parameters.SMTPRelayServerName,


                                        parameters.SMTPPortNumber,


                                        parameters.SMTPUserName,


                                        SysEmailParameters::password(),


                                        parameters.SMTPUseNTLM,parameters.SMTPRequireSSL);

                    }

                    else

                    {

                        warning("ServerNotFound");

                    }

                    if (messageTable.EmailId)

                    {

                        builder.setFrom(parameters.SMTPUserName);

                        

                            builder.addTo(conPeek(con, i)).setSubject(strFmt("%1",messageTable.Subject + ledgerJournaltable.JournalNum)).setBody(SysEmailMessage::stringExpand(messageTable.Mail, SysEmailTable::htmlEncodeParameters(templateTokens)));

                         

                        SysMailerFactory::getNonInteractiveMailer().sendNonInteractive(builder.getMessage());

                        info('Mail successfully sent');

                    }

        }

     }

        catch (Exception::Error)

        {

            throw error("@SYS326780");

        }

    }

Step 2:-Configure template name in frontend 

Path:-

System administration > Setup > Email > System email templates

 


Thank you!!
Note:-Don't forget to configure SMTP details in front end and make sure done with Test connection

Monday, January 19, 2026

Debug In D365fo with Tier 2 environment database

 Today in this blog we will see how to debug in d365fo with Tier2 env's(uat,gc,preprod)

Step 1:-  Request JIT access 

If you have LCS access take JIT by providing IP of DEV Env  or else

Request from Admin We will get credentials in the format shown below


Servername/DBname

Username

Password

Step 2:- Turn off All Services like w3,worldwide,batches services 

Step 3:- Go to Folder from Filemanger K>AOSService\webroot as shown in image below and locate webconfig file

Step 5:- Copy the file and place it on desktop as back once debugging we need make back local DB

Step 6:- After that Right Click and open with latest visual studio(VS2022) as shown in below

Step 7:- After opening the file Press ctrlf and search AXDB and what ever credentials we got from LCS Replace with them as shown in below

Step 8:- After that for password ctrlf search for Password then change for Databaseacces.Sqlpwd as shown in below

Step 9:-  Save the changes and restart all  services and start debugging !!

Step 10:- Once you finish the process down the services and replace file and Turn on services to get back to normal


Thank You!!

Tuesday, December 9, 2025

Get ledger dimension description beside dimension in d365fo x++

 In this blog we learn how to Get ledger dimension description beside dimension in d365fo x++


Step1)write a display method in table and give in formdatasource

logic:-

       [ExtensionOf(tableStr(BudgetTransactionLine))]

internal final class DaxBudgetTransactionLine_Extension
{
        public display str descriptionLedger()
    {
        str                                 descriptionLedgerLoc = '';

     boolean                             first = true;
     DimensionAttributeLevelValueAllView view,viewloc;
     DimensionAttributeValue             dimValue;
     DimensionAttributeValueGroup        dimensionAttributeValueGroup;
     container                           con;

 

     select firstonly viewloc
         where viewloc.ValueCombinationRecId==this.LedgerDimension;


     while select view order by view.ValueOrdinal asc 
         where view.ValueCombinationRecId == this.LedgerDimension 
&& view.DimensionAttributeValueGroup==viewloc.DimensionAttributeValueGroup

     {
         dimValue = DimensionAttributeValue::find(view.AttributeValueRecId);

         if (!conFind(con,view.AttributeValueRecId))
         {
             con += [view.AttributeValueRecId];
             if (dimValue)
             {
                 if (!first)
                 {
                     descriptionLedgerLoc += " - ";
                 }

                 descriptionLedgerLoc += dimValue.getName();
                 first = false;
             }
         }
     }

     return descriptionLedgerLoc;
}

}

 

 

 Output:-

Wednesday, November 19, 2025

Filter Attachments Docuref when attachments are attached from standard and through custom

 [ExtensionOf(formDatasourceStr(DocuView,DocuRef))]

final class DaxDocuViewForm_Extension
{
    void initValue()
    {
        DocuRef      docuref;
        next initvalue();
        //Args args = element.args();
        //PurchTable     purchtable = args.record();
        if(element.args().menuitemname() == menuitemdisplaystr(Dax_VendorattachmentMenuitem))
        {
            docuref.DAX_NoYes = NoYes::Yes;
        }
        else
        {
            docuref.DAX_NoYes = NoYes::No;
        }
    }
}


and in Docuhistory:-

internal final class Dax_DocuHistoryTable
{

    [DataEventHandler(tableStr(DocuHistory), DataEventType::Inserted)]
    public static void DocuHistory_onInserted(Common sender, DataEventArgs e)
    {
        DocuHistory docuHistory = sender as DocuHistory;
        DocuHistory docuHistoryloc;
        DocuRef     docuRef;
        if(docuHistory.DocuValueDeleted==NoYes::No)
        {
            if (!docuHistory)
            return;

 

            select firstonly docuRef
                where docuRef.RecId == docuHistory.DocuRefRecId;

 

                if (docuRef)
                {
                    ttsbegin;
                    docuHistory.selectForUpdate(true);
                    docuHistory.Dax_IsCustomAttachment = docuRef.DAX_NoYes;
                    docuHistory.update();
                    ttscommit;
                }
        }
        else
        {
            if (!docuHistory)
            return;
            select firstonly docuHistoryloc
                where docuHistoryloc.DocuRefRecId==docuHistory.DocuRefRecId
&& docuHistoryloc.DocuValueDeleted==NoYes::No;
            ttsbegin;
            docuHistory.selectForUpdate(true);
            docuHistory.Dax_IsCustomAttachment =docuHistoryloc.Dax_IsCustomAttachment;
            docuHistory.update();
            ttscommit;

 

        }
    }

 

}

Tuesday, November 18, 2025

Highlight text of record based on condition in d365fo x++

 public void displayOption(Common _record, FormRowDisplayOption _options)

{

    WorkflowWorkItemTable workflowWorkItemTable;


    select workflowWorkItemTable

        where workflowWorkItemTable.Status==WorkflowWorkItemStatus::Pending

        && workflowWorkItemTable.UserId==curUserId()

        && workflowWorkItemTable.RefRecId==_record.RecId

        && workflowWorkItemTable.RefTableId==tableNum(BudgetTransactionLine);


    BudgetTransactionLine  budgetTransactionLine=_record;

    if(workflowWorkItemTable)

    {

        _options.textColor(WinAPI::RGB2int(0, 150, 0));

    }

    next displayOption(_record,_options);

}

Write a condition on HTML editor control if it is having value in d365fo x++

 Htmleditor htmledc=formRun.design().controlName("YourHtmlEditorControlName") as Htmleditor;

if(htmledc.parmHtmlContent())

{write condtion}

Wednesday, October 22, 2025

Get salestax amount of each individual purchline

 Scenario:- In this post we see how we can get salestax amount of a purchline from purchase order

code:-

PurchTable purchTable =PurchTable::find('00000400');
PurchTotals purchTotals = PurchTotals::newPurchTable(purchTable);
purchTotals.calc();
TmpTaxWorkTrans tmpTaxWorkTrans;
tmpTaxWorkTrans.setTmpData(purchTotals.tax().tmpTaxWorkTrans());

real salestax;

while select * from tmpTaxWorkTrans
     where tmpTaxWorkTrans.SourceRecId == Pass Purchlinerecid
{
     // Process the tax information for the specific line
     salestax+=tmpTaxWorkTrans.TaxAmount;
}

info(strfmt("SalesTaxamount:-%1",salestax));
---------------------------------------------------------------------------------------------------------------------

Scenario:- In this post we see how we can get salestax amount of a pendingvendor invoice without po
note:-actually this code works for both

code:-

VendInvoiceInfoTable vendInvoiceInfoTable= VendInvoiceInfoTable::findRecId(5637973306);
PurchTotals purchTotals = PurchTotals::newParmTable(vendInvoiceInfoTable,PurchUpdate::All,vendInvoiceInfoTable.ParmId,
             '',
             vendInvoiceInfoTable.Ordering,
             PurchTotalsCachingMethod::Reuse);

 

purchTotals.calc();

AmountCur taxAmount = purchTotals.taxTotal();
Info(strFmt("Subtotal: %1", taxAmount));

computed column in Dataentity

synatx:-    public static server str methodname()   {       str purchid=SysComputedColumn::returnField(dataentityviewstr(Dataentityname),d...