Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 72043

Edit / Lookup method

$
0
0

Hello,

I'm having trouble using the lookup or edit method.

In "create non conformance" form I want to display Operation names based on the type "Operation" and whatever value is in "Reference number" field.

I have added operation ID field in Table extension. With visible false.

I have also added Name in the table and in field group which is used on form.

The goal is this field to be lookup, which will show the list of "Route operation IDs" from table ProdRoute table / form and when selected you should get the name of that Operation.

Relations between tables are:

InventNonConformanceTable.InventRefId == ProdRoute.ProdId

ProdRoute.OprId == RouteOprTable.OprId

and I want to get RouteOprTable.Name value in my lookup field.

I didn't find much info about using of Edit method (Is it even possible to use in my case, as I want to display columns of one table when you click down arrow and when selected it to show the value from referenced table?)

For the lookup, I tried to build the method in table extension class, but I'm getting empty lookup.

Here is the code, which is not fully implemented with desired logic. Was just trying to be able to display columns from ProdRoute table.

[ExtensionOf(tablestr(InventNonConformanceTable))]
final class InventNonConformanceTableCreateXXX_Extension
{
    public static void routoprNameLookup(FormControl    _control,
                                        InventRefId   _inventRefId)
    {
        Query                   query;
        QueryBuildDataSource    qbds;
        QueryBuildRange         qbr;
        SysTableLookup          lookup;

        query = new Query();
        qbds = query.addDataSource(tableNum(ProdRoute));
        qbds = qbds.addDataSource(tableNum(InventNonConformanceTable));
        qbds.joinMode(JoinMode::InnerJoin);
        qbds.addLink(fieldNum(InventNonConformanceTable, InventRefId), fieldNum(ProdRoute, ProdId));
        qbr = qbds.addRange(fieldNum(ProdRoute, ProdId));
        qbr.value(queryValue(_inventRefId));

        lookup = SysTableLookup::newParameters(tableNum(InventNonConformanceTable), _control, true);

        lookup.parmQuery(query);
        lookup.addLookupfield(fieldNum(RouteOprTable, OprId));
        lookup.addLookupfield(fieldNum(RouteOprTable, Name));

        lookup.performFormLookup();
    }

}


And in form extension class I have:

[extensionOf(formStr(InventNonConformanceTableCreate))]
final class InventNonConformanceFormCreateXXX_Extension
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormControlEventHandler(formControlStr(InventNonConformanceTableCreate, myFormCOntrol), FormControlEventType::Lookup)]
    public void tmuTest_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        InventNonConformanceTable::routoprNameLookup(sender, this.InventNonConformanceTable.InventRefId);
        FormControlCancelableSuperEventArgs cancelSuper = e as FormControlCancelableSuperEventArgs;

        cancelSuper.CancelSuperCall();
    }

}




Viewing all articles
Browse latest Browse all 72043

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>