Friday, March 15, 2019

How to perform a Lookup for a particular FinancialDimension using X++?

{
    SysTableLookup                      sysTableLookup;
    Query                               query;
    QueryBuildDataSource                qbdsDimensionFinancialTag;
    QueryBuildRange                     qbrFinancialTagCategory;

    #define.MyCustomFinancialDimension('Divisions')

    query = new Query();
    qbdsDimensionFinancialTag = query.addDataSource(tableNum(DimensionFinancialTag));
    qbrFinancialTagCategory = qbdsDimensionFinancialTag.addRange(fieldNum(DimensionFinancialTag, FinancialTagCategory));
    qbrFinancialTagCategory.value(strFmt('%1', DimensionAttribute::findByName(#MyCustomFinancialDimension, false).financialTagCategory()));

    sysTableLookup = sysTableLookup::newParameters(tableNum(DimensionFinancialTag), this);
    sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Value), true);
    sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Description));
    sysTableLookup.addSelectionField(fieldNum(DimensionFinancialTag, FinancialTagCategory));
    sysTableLookup.parmQuery(query);

    sysTableLookup.performFormLookup();
}

1 comment:

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// ...