Monday, 30 July 2018

Creating custom financial dimension Lookup using X++ code in AX / D365FO / AX 7


Here is the sample X++ code to create custom financial dimension lookup

public void Lookup(FormStringControl _control)
{
        DimensionAttribute                  dimensionAttribute;
        DimensionAttributeDirCategory       dimAttributeDirCategory;
        Query                               query = new Query();
        SysTableLookup                      sysTableLookup;

        dimensionAttribute = DimensionAttribute::findByName('ServiceLine');

        if (dimensionAttribute.Type == DimensionAttributeType::CustomList)

        {

        select firstonly DirCategory from dimAttributeDirCategory
            where dimAttributeDirCategory.DimensionAttribute == dimensionAttribute.RecId;

        sysTableLookup = SysTableLookup::newParameters(tableNum(DimensionFinancialTag), _control);

        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...