Tuesday, 31 August 2021

Financial Dimension Lookup using X++ in Ax 2012 and D365 for Finance and operations

X++ code to create  Financial Dimension Lookup by name

public void LocationDimLookup(FormStringControl _control)
{
    DimensionAttribute                  dimensionAttribute;
    DimensionAttributeDirCategory       dimAttributeDirCategory;
    Query                               query = new Query();
    SysTableLookup                      sysTableLookup;
    dimensionAttribute = DimensionAttribute::findByName('Location');

    if (dimensionAttribute.Type == DimensionAttributeType::CustomList)
    {
        select firstonly DirCategory from dimAttributeDirCategory where dimAttributeDirCategory.DimensionAttribute == dimensionAttribute.RecId;
        sysTableLookup = SysTableLookup::newParameters(tableNum(DimensionFinancialTag), _control);

        // Add name field to be shown in the lookup form.
        sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Value));
        sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Description));

        query = new Query();
        query.addDataSource(tableNum(DimensionFinancialTag)).
        addRange(fieldNum(DimensionFinancialTag, FinancialTagCategory)).
        value(queryValue(dimAttributeDirCategory.DirCategory));
        sysTableLookup.parmQuery(query);

        // Perform the lookup.
        sysTableLookup.performFormLookup();
    }
}

No comments:

Post a Comment

Difference Between Edit And Display Method in Ax

Display Method: The display method means that the method’s return value is being displayed on a form or a report.  This value is fixed and c...