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());
                }
    }

}

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...