D365 Finance & Operations and Dynamics AX Forum

Expand all | Collapse all

D365F - Form Lookup Override via CoC?

  • 1.  D365F - Form Lookup Override via CoC?

    Posted Jul 13, 2020 07:00 PM
    Has anybody ever successfully overridden a form control dropdown in F&O using Chain of Command instead of the event-handler-based approach?  It seems to me that all the pieces are there, but I haven't had success the few times I've tried.

    #FinanceAndOperations #Technical #Advanced​​​​​

    ------------------------------
    Ian Jensen
    ERP Technical Manager
    Czarnowski
    Denver CO
    ------------------------------
    The first step toward cloud success. - Migrate from AX to D365 with expert guidance from Microsoft. I'm Ready


  • 2.  RE: D365F - Form Lookup Override via CoC?

    Posted Jul 14, 2020 11:32 AM
    I even tried that to no avail! Am eager to see those who did and they did it.

    ------------------------------
    Huggins Mafigu
    Infinite Business Technology Solutions
    Harare
    ------------------------------

    The first step toward cloud success. - Migrate from AX to D365 with expert guidance from Microsoft. I'm Ready


  • 3.  RE: D365F - Form Lookup Override via CoC?

    Posted Jul 14, 2020 12:42 PM
    RIGHT??  Same - I was able to build an override using CoC in a few different ways which all compile, but when I actually try to open the control, the server crashes!  So .. for now, I feel like we're stuck with event handlers, which is a real pain when we're building most other customizations using Chain of Command.

    ------------------------------
    Ian Jensen
    ERP Technical Manager
    Czarnowski
    Denver CO
    ------------------------------

    The first step toward cloud success. - Migrate from AX to D365 with expert guidance from Microsoft. I'm Ready


  • 4.  RE: D365F - Form Lookup Override via CoC?

    Posted Jul 14, 2020 04:12 PM

    Figured it out:

    [ExtensionOf(formstr(ExampleForm))]
    final class ExampleForm_FormIan_Extension
    {    
        void init()
        {
            //Assumes TargetControl is auto-declared, but we can get to it even if it's not
            TargetControl.registerOverrideMethod(methodStr(FormDataObject, lookup), formMethodStr(ExampleForm, ianCustomLookup));
        }
    
        public void ianCustomLookup(FormStringControl _callingControl)
        {
            SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(SomePertinentTable), _callingControl);
    
            sysTableLookup.addLookupfield(fieldNum(SomePertinentTable, UsefulField1), true);
            sysTableLookup.addLookupfield(fieldNum(SomePertinentTable, UsefulField2));
    
            Query q = new Query();
    
            q.addDataSource(tableNum(SomePertinentTable)).addRange(fieldNum(SomePertinentTable, NoYesFieldIWantToConstrain)).value(queryValue(NoYes::No));
    
            // Run lookup
            sysTableLookup.parmQuery(q);
            sysTableLookup.performFormLookup();
        }
    }


    ------------------------------
    Ian Jensen
    ERP Technical Manager
    Czarnowski
    Denver CO
    ------------------------------

    The first step toward cloud success. - Migrate from AX to D365 with expert guidance from Microsoft. I'm Ready


  • 5.  RE: D365F - Form Lookup Override via CoC?

    Posted Jul 15, 2020 11:31 AM
    How where you doing it in the first place??

    ------------------------------
    Huggins Mafigu
    Infinite Business Technology Solutions
    Harare
    ------------------------------

    The first step toward cloud success. - Migrate from AX to D365 with expert guidance from Microsoft. I'm Ready


If you've found this thread useful, dive deeper into User Group community content by role