Skip to main content

Notifications

Community site session details

Community site session details

Session Id :

Enable and Disable Vendor invoice button on PO list and details page X++

Muhammad Uzair Shah Profile Picture Muhammad Uzair Shah 201

Hi folks,

This blog will be useful where vendor invoice process is required to be controlled based on certain conditions.

Requirements:

Procurement department wants to have control on Vendor invoicing process due to which they need PO on hold for Vendor Invoice functionality. 

Once, the PO is on hold then users shouldn't be able to process the invoice which means that Vendor invoice button should be disabled for on hold POs.

Solution:

Standard Microsoft "PurchTableType" class is responsible for handling the logic related to enabling and disabling of controls on the action pane of PO list and details page therefore extending the logic on this class is suffice to fulfill the requirements.

I added the custom onhold flag field as a control field to enable or disable the Vendor invoice button. You can apply your logic based on your requirements. 

"CanInvoiceBeUpdated" is the method which is being called to enable and disable Vendor invoice button on PO list and details page and returns boolean value. If this method returns false then Vendor invoice button will be disabled otherwise enabled.

Below is the code snippet of the solution:

[ExtensionOf(classStr(PurchTableType))]  
final class DemoPurchTableType_Extension  
{  
    public boolean canInvoiceBeUpdated(boolean _excludePending)  
    {  
        next canInvoiceBeUpdated(false);  
   
        //You can apply your logic here.  
        if(this.purchTable.OnHold == NoYes::Yes)  
        {   
            return false;  
        }  
    }
}

Comments

*This post is locked for comments