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

How to filter an existing lookup field on SalesTable form while creating a new sales order

$
0
0

Hi

While creating a new sales order, their are two fields in that form- Customer Account in Customer Tab & Invoice Account in General Tab, Initially , these two fields are lookup fields which Populate Customer Account Number from CustTable & Invoice Account field is getting initialized as soon as we choose value in Customer Account field & with the same account number we choose in Customer Account field.

I need to filter the records in Invoice Account field as per the customer group of the Account number we choose in Customer Account field.

for ex, if we choose Account no- DE-010 (let say Customer Group- 10) in Customer Account lookup field then Invoice Account lookup field should be filter & shows only records which has Customer Group 10. This functionality I need in my instance.

I have tried to write Chain of Extension for the salesTable at formDataFieldStr, I am attaching my code below-

[ExtensionOf(formDataFieldStr(SalesTable,SalesTable,InvoiceAccount))]
final class HSHTSalesTable_FormDataFieldStr_Extension
{
    public void lookup(FormControl _formControl, str _filterStr)
    {
        Query                           query = new Query();
        QueryBuildDataSource            queryBuildDataSource;
        QueryBuildRange                 queryBuildRange;
        SalesTable                      salesTable;
        next lookup(_formControl, _filterStr);
        SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(CustTable), _formControl);
        queryBuildDataSource = query.addDataSource(tableNum(CustTable));

        //queryBuildDataSource.addSelectionField(fieldnum(CustTable,AccountNum));

        queryBuildRange = queryBuildDataSource.addRange(fieldNum(CustTable,CustGroup));

        queryBuildRange.value(queryValue(CustTable::find(salesTable.CustAccount).CustGroup));

        sysTableLookup.addLookupfield(fieldNum(CustTable, AccountNum));
        sysTableLookup.addLookupfield(fieldNum(CustTable, CustGroup));

        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    
    }

}

I am attaching images as well for the refernce-


Viewing all articles
Browse latest Browse all 175888

Trending Articles



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