Search code examples
formsaxaptalookupdynamics-ax-2012x++

How to Create Lookup by Account Type using DimensionDynamicAccountController?


I have a problem. I have in my new table two new fields

1) Name -> AccountNum, EDT--> DimensionDynamicAccount

2) Name -> AccountType, EDT--> LedgerJournalACType

class declaration

:

public class FormRun extends ObjectRun
{
    DimensionDynamicAccountController dimAccountController;
}

init (for the form):

public void init()
{
   super();
   dimAccountController = DimensionDynamicAccountController::construct(
   MyTable_ds,
   fieldstr(MyTable, LedgerDimension),
   fieldstr(MyTable, AccountType));
}

4. Override the following methods on the Segmented Entry control instance in the form design.

public void jumpRef()
{
    dimAccountController.jumpRef();
}

public void loadAutoCompleteData(LoadAutoCompleteDataEventArgs _e)
{
    super(_e);
    dimAccountController.loadAutoCompleteData(_e);
}

public void segmentValueChanged(SegmentValueChangedEventArgs _e)
{
    super(_e);
    dimAccountController.segmentValueChanged(_e);
}

public void loadSegments()
{ 
   super();
   dimAccountController.parmControl(this);
   dimAccountController.loadSegments();
}

public boolean validate()
{
    boolean isValid;
    isValid = super();
    isValid = dimAccountController.validate() && isValid;
    return isValid;
}

5. Override the following methods on the data source field that backs the Segmented Entry control.

public Common resolveReference(FormReferenceControl _formReferenceControl)
{
   return dimAccountController.resolveReference();
}

Now my problem is Lookup only works for AccountType=="Ledger" not for customer, Vendor etc...

If I have a AccountType == Vendor or similant but different to Ledger I see this emptyLookup

I would want to have same the same thing that's in the LedgerJournalTrans Form

There is a solution,

thanks all,

enjoy


Solution

  • This might be too obvious, but I think you're missing the lookup() method.

    See:

    \Forms\LedgerJournalTransDaily\Designs\Design\[Tab:Tab]\[TabPage:OverViewTab]\[Grid:overviewGrid]\SegmentedEntry:LedgerJournalTrans_AccountNum\Methods\lookup

    public void lookup()
    {
        if (!ledgerJournalEngine.accountNumLookup(ledgerJournalTrans_AccountNum,
                                                    ledgerJournalTrans,
                                                    ledgerJournalTrans.OffsetAccountType,
                                                    ledgerJournalTrans.parmOffsetAccount(),
                                                    ledgerJournalTrans_Asset))
        {
            super();
        }
    }