Monday, December 12, 2022

D365 F&O Warehouse management application customization Part 1- Auto populate the value to a standard field.

Hi All,
I hope everyone is doing great and learning new things. 
Here I am coming with a new blog to understand and guide everyone to learn the customization in Warehouse Management application. As you can see in the screenshot below, We have received by purchase order form on this form we will scan the QR string and auto populate the remaining field values.

This is the example of QR string format:  "PoNum,ItemId,Quantity,date"



As I understand from the code WHSWorkExecuteDisplay.displayForm() is the important method to create control and assign the values. It is an abstract method of class WHSWorkExecuteDisplay so that according to our requirement we need to figure out under which process you need to implement your changes to and then find its child class.

In my example child class WHSWorkExecuteDisplayPOReceiving so I have created an extension class for it and added COC for displayForm() method.

[ExtensionOf(classStr(WHSWorkExecuteDisplayPOReceiving))]
final class WHSWorkExecuteDisplayPOReceiving_ModelTest_Extension
{
    
}

All the controls on the form and its values are assigned through the container of display form method parameter(_con). so, to assign our values we need modify the same container.

below logic will take scanned value of QR code from PONum field then convert it to the container.

// COC of display form method in extension class.
 public container displayForm(container _con, str _buttonClicked)
 {
    if( mode == WHSWorkExecuteMode::PurchaseOrderItemReceivingAndLocate &&
         step == 1)
    {
            container      returnedCon, qrValueContainer;
            PurchId         purchId;
            ItemId           itemId;
            str                 quantityStr;
            const str       fullQRValueConstText        = "FullQRValue";
            #WHSWorkExecuteControlElements
            #WHSRF

            str  fullQRValue = this.getControlDataFromContainer(_con,#PONum);
        
            qrValueContainer = str2con(fullQRValue,'@');

            if(conLen(qrValueContainer) > 1)
            {
                pass.insert(fullQRValueConstText, fullQRValue);

                purchId       =  conPeek(qrValueContainer,1);
                quantityStr  =  conPeek(qrValueContainer,2);
                itemId         =  conPeek(qrValueContainer,3);

                _con = this.setControlDataFromContainer(_con, #PONum, purchId);
                stepLocal = step;
            }

        returnedCon = next displayForm(_con, _buttonClicked);
    
           if( mode == WHSWorkExecuteMode::PurchaseOrderItemReceivingAndLocate)
            {
                    // you can add logic here when to replace.
                    if(stepLocal == 1 && pass.lookup(#PONum) != '')
                    {
                        returnedCon  this.setControlDataFromContainer(returnedCon,                                                                                         #Qty,  strRem(quantityStr,'Q'));
                        returnedCon = this.setControlDataFromContainer(returnedCon, #ItemId, itemId);                        
                    }
            }
    }
    return returnedCon;
 }    

That's It. Happy Coding.
Please comment if you have faced any challenge to implement this.

No comments:

Post a Comment

How to Post Partial Product Receipt in D365FO Using X++ Code

How to Post Partial Product Receipt in D365FO Using X++ Code How to Post Partial Product Receipt in D365FO Using X++...