Tuesday, September 2, 2025

How to Retrieve the Purchase Order Number in the LedgerTransAccount Form using X++ in D365 Finance & Operations

 How to Retrieve the Purchase Order Number in the LedgerTransAccount Form using X++ in D365 Finance & Operations

[ExtensionOf(tableStr(GeneralJournalEntry ))]

internal final class GeneralJournalEntryTable_Extension

{

 public display Name Ponumber()

    {

        Name                    ret;  

        VendInvoiceJour         VendInvoiceJour;

        VendTrans               VendTrans;

        VENDPACKINGSLIPVERSION  VENDPACKINGSLIPVERSION;

        VENDPACKINGSLIPJOUR     VENDPACKINGSLIPJOUR;


        select VendTrans

            where VendTrans.Voucher == this.SubledgerVoucher;


        select VendInvoiceJour where VendInvoiceJour.LedgerVoucher ==VendTrans.Voucher

            &&  VendInvoiceJour.InvoiceAccount ==VendTrans.AccountNum

            &&  VendInvoiceJour.InvoiceDate ==VendTrans.TransDate;

        if(VendInvoiceJour)

        {

            ret = VendInvoiceJour.PurchId;

        }

        

        SELECT VENDPACKINGSLIPJOUR FROM VENDPACKINGSLIPVERSION

            WHERE VENDPACKINGSLIPVERSION.LEDGERVOUCHER ==this.SubledgerVoucher;


        SELECT PACKINGSLIPId FROM VENDPACKINGSLIPJOUR

            WHERE VENDPACKINGSLIPJOUR.RECID == VENDPACKINGSLIPVERSION.VENDPACKINGSLIPJOUR;

        if(VENDPACKINGSLIPJOUR)

        {

            ret = VENDPACKINGSLIPJOUr.purchid;

        }


        return ret;

    }

}

If a How to get Purchase Order (PO) is linked to a Purchase Requisition (PR), fetch the Name from the PR and populate it in the Description field of the Product Receipt form.

 If a Purchase Order (PO) is linked to a Purchase Requisition (PR), fetch the Name from the PR and populate it in the Description field of the Product Receipt form.


[ExtensionOf(formDataSourceStr(PurchEditLines,PurchParmTable))]

internal final class PurchParmTableFormDataSource_Extension

{

    public void executeQuery()

    {

        next executeQuery();

        PurchReqTable purchReqTable;

        PurchReqLine  purchReqLine;

        FormStringControl   Invoicedescription = this.formRun().design().controlName("PurchParmTable_Description");

        PurchParmTable purchParmTable = this.cursor();

 

  

        select firstOnly purchReqLine

            where purchReqLine.PurchId == purchParmTable.PurchId

            && purchReqLine.INVENTDIMIDDATAAREA == purchParmTable.DataAreaId;

           

        if (purchReqLine.RecId)

        {

       

            select firstOnly purchReqTable

                where purchReqTable.RecId == purchReqLine.PurchReqTable;

 

            if (purchReqTable.RecId)

            {

               

                purchParmTable.Description = purchReqTable.PurchReqName;

                Invoicedescription.allowEdit(false);


            }

        }

        else

        {

            

            FormStringControl descriptionCtrl =  this.formRun().design().controlName('PurchParmTable_Description'); // Control name in the form

               

            if (descriptionCtrl)

            {

                descriptionCtrl.mandatory(true);

            }

        }

    

 

 

    }


}

Tuesday, June 3, 2025

How to find country region code in D365 fo X++

 How to find the country region code in D365 for X++

LogisticsAddressCountryRegion::findByISOCode(SysCountryRegionCode::countryInfo(curext())).CountryRegionId



Monday, May 5, 2025

How to Retrieve Personnel Number for a Specific User in Dynamics 365 F&O

 In SQL:-

    

SELECT 

    HW.PersonnelNumber,

    PU.USER_

FROM 

    HcmWorker AS HW

JOIN 

    DirPersonUser AS PU ON HW.Person = PU.PersonParty

WHERE 

    PU.USER_ = 'Akhil';

Wednesday, April 9, 2025

Creating a Global Action Button in D365 Accounts Payable Parameters

Creating a Global Action Button in D365 Accounts Payable Parameters.

[FormControlEventHandler(formControlStr(VendParameters, VendParameters_YNV_VendorMasterDeletionOption), FormControlEventType::Modified)]

    public static void VendParameters_YNV_VendorMasterDeletionOption_OnModified(FormControl sender, FormControlEventArgs e)

    {

        VendParameters          vendParameters;

        FormCheckBoxControl     formCheckBoxControl = sender as FormCheckBoxControl;

        ttsBegin;

        while select

            forUpdate crossCompany

                YNV_VendorMasterDeletionOption,DataAreaId

            from

            vendParameters where vendParameters.DataAreaId != curExt()

        {

            changeCompany(vendParameters.dataAreaId)

            {

                vendParameters.YNV_VendorMasterDeletionOption = formCheckBoxControl.checked();

                vendParameters.update();

            }

        }

        ttsCommit;

    } 

Tuesday, April 8, 2025

My requirement is that the grid fields should not be editable for a particular formdatasource.

Based on the condition, grid fields should not be editable for a particular form datasource.

[ExtensionOf(formDataSourceStr(LedgerJournalTransVendPaym, LedgerJournalTrans))]

public final class YNV_LedgerJournalTransVendPaym_LedgerJournalTransDatasource_Extension


      public int active()

   {

      

      LedgerJournalTrans          LedgerJournalTrans       = this.cursor();

      VendParameters              vendParameters           = vendParameters::find();

      FormDataSource              LedgerJournalTrans_ds    = this;

      FormDataSource              LedgerJournalTrans_W_ds  = this.formRun().dataSource(formDataSourceStr(LedgerJournalTransVendPaym,LedgerJournalTrans_W ));

      LedgerJournalTrans_W        LedgerJournalTrans_W     = LedgerJournalTrans_W_ds.cursor();

      


       int ret = next active();


        if(vendParameters.YNV_EditVendPaymProposal == NoYes::Yes)

        {

            if(LedgerJournalTrans.YNV_IsPaymProposal == NoYes::Yes)

            {

                allowEditFieldsOnFormDS_W(LedgerJournalTrans_ds, false);

                allowEditFieldsOnFormDS_W(LedgerJournalTrans_W_ds, false);


                LedgerJournalTrans_ds.object(fieldNum(LedgerJournalTrans, Txt)).allowEdit(true);

                LedgerJournalTrans_ds.object(fieldNum(LedgerJournalTrans, TransDate)).allowEdit(true);

                LedgerJournalTrans_W_ds.object(fieldNum(LedgerJournalTrans_W, ServiceLevel)).allowEdit(true);

                LedgerJournalTrans_W_ds.object(fieldNum(LedgerJournalTrans_W, ChargeBearer)).allowEdit(true);

            }

            else

            {

                allowEditFieldsOnFormDS_W(LedgerJournalTrans_ds, true);

                allowEditFieldsOnFormDS_W(LedgerJournalTrans_W_ds, true);

            }

        }

        else

        {

            allowEditFieldsOnFormDS_W(LedgerJournalTrans_ds, true);

            allowEditFieldsOnFormDS_W(LedgerJournalTrans_W_ds, true);

        }

              return ret;

}


How to Retrieve the Purchase Order Number in the LedgerTransAccount Form using X++ in D365 Finance & Operations

 How to Retrieve the Purchase Order Number in the LedgerTransAccount Form using X++ in D365 Finance & Operations [ExtensionOf(tableStr(G...