Tuesday, September 2, 2025

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

            }

        }

    

 

 

    }


}

No comments:

Post a Comment

Automating Consolidate Account Updates for New Voucher Transactions in D365 Finance and Operations

  Ensure the  Consolidate Account  field is automatically updated for all new voucher transactions based on the  Consolidate MainAccount set...