Saturday, October 31, 2015

AX 2012 :Financial Dimensions Lookup

add this logic into your lookup method and pass dimensionAttributeName = your dimension name
    Args                    args;
    FormRun                 lookupFormRun;
    DimensionAttribute      dimAttr;
    Object                  object;
    Name                    dimensionAttributeName;
    LTFinDimLink                        ltFinDimLink;

    select * from ltFinDimLink;
    if(FinDimLink.DimensionForColor)
    {
      dimensionAttributeName =   FinDimLink.color;
    }
    if (_ctrl != null)
    {
        // Construct arguments for the custom lookup
        args = new Args();
        args.name(formStr(DimensionDefaultingLookup));
        args.lookupValue(_ctrl.text());
        args.caller(_ctrl);

        // Find the dimension attribute associated with the string control which called this method
        dimAttr = DimensionAttribute::findByLocalizedName(dimensionAttributeName);
        args.lookupField(dimAttr.ValueAttribute);
        args.record(dimAttr);

        // Run the custom lookup and init the lookup form
        lookupFormRun = classfactory.formRunClass(args);
        lookupFormRun.init();

        // Specify this is the callback on the lookup form by casting the
        // form to an object and late binding the setResultCallback method
        if (SysFormRun::hasMethod(lookupFormRun, identifierStr(setResultCallback)))
        {
            object = lookupFormRun;
            object.setResultCallback();
        }

        _ctrl.performFormLookup(lookupFormRun);

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8