Review of child table selection using extension table framework

To continue with table extension framework topic let's review how it tries to fetch dependent table from main:
  • From dependent DataSource on form. Only heaving taught join like outer/inner. Delayed will not work, however you can still fix that using SysExtensionSerializerFormRunHelper class
  • Joined datasource in selection like select ... join or Query class
  • From field PackedExtensions at parent table
  • Fetching from DB

You can find the logic of child table fetching in SysExtensionSerializerMap::getExtensiontable method:


You can set breakpoints here and using project from first post related to extension tables and following job ensure that it behaves as expected.
static void TableExtensionFetch(Args _args)
{
    TableExtensionParent    parent;
    TableExtensionChild     child,
                            child2;

    Query                   q = new Query();
    QueryBuildDataSource    qbdsParent,
                            qbdsChild;
    QueryRun                qr;

    FormRun                 formRun;
    Object                  formRunObject;
    Args                    args = new Args();

    // Form DataSource
    args.name(formstr(TableExtensionForm));
    formRun = ClassFactory.formRunClass(args);
    formRun.init();
    formRun.run();
    formRun.wait();
    if (formHasMethod(formRun, identifierStr(getParentTable)))
    {
        formRunObject       = formRun;
        parent              = formRunObject.getParentTable();
        child               = parent.tableExtensionChild();
    }

    parent = null;
    parent.clear();
    child.clear();
    child2.clear();

    // Joined table 1
    select firstonly parent
        join child
            where child.TableExtensionParent == parent.RecId;

    child2 = parent.tableExtensionChild();


    parent.clear();
    child.clear();
    child2.clear();
    
    // Joined table 1
    qbdsParent  = q.addDataSource(tableNum(TableExtensionParent));
    qbdsParent.firstOnly(true);
    qbdsChild   = qbdsParent.addDataSource(tableNum(TableExtensionChild));
    qbdsChild.relations(true);

    qr = new QueryRun(q);
    while (qr.next())
    {
        parent  = qr.get(tableNum(TableExtensionParent));
        child   = parent.tableExtensionChild();
    }

    parent.clear();
    child.clear();
    child2.clear();

    // packed
    child.AdditionalField = 'packed';
    parent.packTableExtensionChild(child);
    child2 = parent.tableExtensionChild();

    parent.clear();
    child.clear();
    child2.clear();
    
    // DB
    select firstonly parent;
    child = parent.tableExtensionChild();

    abs(1);
}

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags