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));

Thursday, September 18, 2025

change lookup for documenttype in file upload from leave request

 Scenario:- Today in this blog we see how to alter lookup of document type based on document type in leave request form as shown in image below


 >>To get lookup of all document types write this logic

[ExtensionOf(classstr(DocuUpload))]
internal final class docucoc_Extension
{
    public DocuManagementOptions parmDocuMgmtOptions(DocuManagementOptions _value )
    {
        DocuManagementOptions docuMgmtOptions = next parmDocuMgmtOptions(_value);
        int num=this.currentTableId();
        if(tableId2Name(num)=="LeaveRequest")
        {this.setupDocuTypescoc();}
        return docuMgmtOptions;
    }

 

    public  void setupDocuTypescoc()
    {
        List            docuTypeList;
        ListIterator    docuTypeListIterator;
        ComboBoxItem    comboxBoxItem;

 

        // Get the list of document types for the primary table
        docuTypeList = DocuUpload::getDocuTypeListcoc();

 

        // Set the list of document types
        this.documentTypes(docuTypeList);

 

        // Initialize the iterator for the list of document types
        docuTypeListIterator = new ListIterator(docuTypeList);

 

        // If the iterator has at least one item, set the selected document type to the first element;
        // otherwise set the selected document to an empty string
        if (docuTypeListIterator.more())
        {
            comboxBoxItem = docuTypeListIterator.value();
            this.selectedDocumentType(comboxBoxItem.parmValue());
        }
        else
        {
            this.selectedDocumentType('');
        }
    }

 

    private static List getDocuTypeListcoc()
    {
        DocuType        docType;
        List            docuTypeList = new List(Types::Class);
        UserInfo        userInfo;

 

        // Get the current language
        select language from userInfo
            where UserInfo.id == curUserId();

 

        // Add all document types that aren't a document library
        while select @TypeId,ActionClassId from docType
            //index TypeIdx
            //where docType.ActionClassId == classNum(DocuActionArchive)
        {
            // If the document type isn't valid, just continue to the next element instead of adding it
            if (DocuEvent::doCheckSkipDocuType(docType))
            {
                continue;
            }

 

            docuTypeList.addEnd(new ComboBoxItem(docType.TypeId, docType.TypeId));
        }

 

        return docuTypeList;
    }

 

}

 

 





Wednesday, September 3, 2025

Filtering records in grid in datasource init method

 This article is about filtering records in grid

>> Generally if it comes to  Filtering records we go for execute query but sometime we see this not that appropriate working so  we go for formdatasource init


code:-

[ExtensionOf(FormDataSourcestr(PurchReqCopyRFQ,PurchReqLine))]
internal final class PurchReqCopyRFQ_Extension
{
    public void init()
    {
        next init();
        QueryBuildRange qbrBuyingLegalEntity;

        FormDataSource          purchReqLine_ds;

       purchReqLine_ds =this as FormDataSource;
       purchReqLine_ds.query().dataSourceTable(tableNum(PurchReqLine)).clearRanges();

        qbrBuyingLegalEntity = this.query().dataSourceTable(tableNum(PurchReqLine)).addRange(fieldNum(PurchReqLine, BuyingLegalEntity));

        qbrBuyingLegalEntity.value(queryValue(CompanyInfo::findDataArea(curExt()).RecId));
        qbrBuyingLegalEntity.status(RangeStatus::Locked);
    }

 

}

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...