Tuesday, July 21, 2020

Grid Row coloring in D365FO

[ExtensionOf(formdatasourcestr(SalesTable, SalesLine))]
Final class SONSalesTableDisplayOption_Extension
{
    public void displayOption(Common _record, FormRowDisplayOption _options)
    {
        InventDimCtrl_Frm_Mov inventDimFormSetup;
        InventDimControlsCollect inventDimControls;
        InventDimFormControlInterface fc;
        SalesLine salesLineLocal =  _record;
        #define.White(255, 255, 255)

        FormDataSource SalesLine_ds = this;
        FormRun formRun = SalesLine_ds.formRun();
        inventDimFormSetup = formRun.inventDimSetupObject();
        FormRealControl SalesLine_SalesQty = formRun.design(0).controlName("SalesLine_SalesQty");

        next displayOption(_record, _options);

        if (saleslineLocal.SalesQty != salesLineLocal.songetInvQty())
                {
                    _options.backColor(WinAPI::RGB2int(255,0,0));

//_options.textColor(WinAPI::RGB2int(#White)); invert color text
        
                    //Mark coloring by inventory dimension
                    inventDimControls = inventDimFormSetup.inventDimControls();
                    for (fc = inventDimControls.first(); fc; fc = inventDimControls.next())
                    {
                        if (fc.visible() && fc.isInGrid())
                                _options.affectedElementsByControl(fc.controlObject().id());
                    }
        
                    _options.affectedElementsByControl(SalesLine_SalesQty.id());
                }
    }

}

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...