post event handler of table method, simple question

Hello, friends

I have an extended system table PurchPurchaseOrderHeader_Extension. I need to add additional field and additional code line in one of the original table methods to fille the fields value. As I understand you can do it with chain of commands or pre-post method event handlers.

This is the original method code:

    public void initFromVendTable(VendTable _vendTable)
    {
        // <GEECZ>
        #ISOCountryRegionCodes
        // </GEECZ>

        this.VendName               = _vendTable.name();
        this.VendAddress            = DirUtility::replaceAddressTokenLanguage(_vendTable.postalAddress(), _vendTable.languageId());

        // <GEECZ>
        if (SysCountryRegionCode::isLegalEntityInCountryRegion([#isoCZ]))
        {
            this.VendRegNum      = _vendTable.getPrimaryRegistrationNumber(TaxRegistrationTypesList::UID);
            this.VendCoRegNum    = _vendTable.getPrimaryRegistrationNumber(TaxRegistrationTypesList::TAXID);
        }
        // </GEECZ>
    }

I need to add code line which fills new field VendVATNum. The code could look like this:

this.VendVATNum = _vendTable.VatNum;

However, when I m little bit confused on how to pass the original methods parameters (_vendTable and this) into post event handler:

    [PostHandlerFor(tableStr(PurchPurchaseOrderHeader), tableMethodStr(PurchPurchaseOrderHeader, initFromVendTable))]
    public static void PurchPurchaseOrderHeader_Post_initFromVendTable(XppPrePostArgs args)
    {	


    }

Best regards,

Roberts

Do you see any reason for using method handlers over CoC? I see only problems and no benefits, therefore I suggest you avoid these handlers completely.

You would have to use methods of args to extract parameter values, either by hard-coding the position or by hard-coding the name and you’d lose all compile-time checking. The reference to the current object can be get by calling args.getThis(), then you’d have to cast it to the right type.

It’s all much simpler and safer with CoC:

public void initFromVendTable(VendTable _vendTable)
{
	next initFromVendTable(_vendTable);
	this.VendVATNum = _vendTable.VatNum;
}

Wow, so clean and simple! Thank you and have a nice weekend!

Best regards,

Roberts