Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Monday, February 25, 2019

COC for form object methods in D365


Hi,
COC- Chain of Commands are used to override the Application suite objects.
In certain cases, like the code with public and protected access specified methods cannot be created a post or pre event handler by coping its event.
In that case we need to go with COC.

This can be achieved by using the keyword ExtensionOf() to load the object and next() as super.
Note: COC class needs to final and method that to be COC can be public access specifier.
Example. COC of form button event.
//[ExtensionOf(formControlStr(FormName, ControlName)]
                [ExtensionOf(formControlStr(PurchTable, Total)]
                Final class COCPurchTable_Extension
                {
                                Public void clicked()
                                {
//Your  code to perform action before the event;
                                                info("COC is called");
                                                next clicked();
//Your  code to perform action before the event;
                                }
                }
Regards,

Friday, January 25, 2019

Getting the field Name in Table modified field event handler in D365

Hi,

can be achieved by args.getArgNum(1);

class XXXXCustTable_EventHandler
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="args"></param>
    [PostHandlerFor(tableStr(CustTable), tableMethodStr(CustTable, modifiedField))]
    public static void CustTable_Post_modifiedField(XppPrePostArgs args)
    {
        CustTable               custTable   =  args.getThis() as CustTable;

        switch (args.getArgNum(1))
        {
            case fieldNum(custTable, CustGroup):
                if(!CustTable.OverrideSpecialMarginCode)
                {
                    custTable.SpecialMarginCode = CustGroup::find(
                                  custTable.CustGroup).SpecialMarginCode;
                }
                break;
        }
    }

}
Thanks,

SQL code to upate one Legal entity banner to all the legal entity in D365

 Hi, update companyimage set  companyimage.Image  = companyimageA.Image  from  ( select Image from companyimage where dataAreaid = 'USF...