Showing posts with label Segmented Entry in ax 2012. Show all posts
Showing posts with label Segmented Entry in ax 2012. Show all posts

Sunday, 28 August 2016

How to filter Segmented Entry based on Account Type in Ax 2012


filter Segmented Entry based on Account Type






  1. Create a form 
  2. Override form Init and write below code 
  3. Take data source as LedgerJournalTrans

public class FormRun extends ObjectRun
{
    DimensionDynamicAccountController   dimAccountController;
    
}
public void init()
{
    super();
    dimAccountController = DimensionDynamicAccountController::construct(ledgerJournalTrans_ds,
                                    fieldStr(LedgerJournalTrans, LedgerDimension),
                                    fieldStr(LedgerJournalTrans, AccountType));
}

 3.Under design override two controls i.e ComboBox and Segmented Entry control

 4.Under Segmented Entry control override below methods and set below code & properties



public void jumpRef()
{
    dimAccountController.jumpRef();
}
public void loadAutoCompleteData(LoadAutoCompleteDataEventArgs _e)
{
    super(_e);
    dimAccountController.loadAutoCompleteData(_e);
}
public void loadSegments()
{
    super();
    dimAccountController.parmControl(this);
    dimAccountController.loadSegments();

}
public void lookup()
{
    switch (LedgerJournalTrans.AccountType)
    {
        case LedgerJournalACType::Bank:
            BankAccountTable::lookupBankAccount(this);
            break;
        case LedgerJournalACType::Cust:
            CustTable::lookupCustomer(this);
            break;
        case LedgerJournalACType::FixedAssets:
            AssetTable::lookupAccountNum(this);
            break;
        case LedgerJournalACType::Ledger:
            super();
            break;
        case LedgerJournalACType::Vend:
            VendTable::lookupVendor(this);
            break;

        default:
            super();
            break;
    }
}
public Common resolveReference()
{
    Common ret;

    ret = dimAccountController.resolveReference();

    return ret;
}
public void segmentValueChanged(SegmentValueChangedEventArgs _e)
{
    super(_e);

    dimAccountController.segmentValueChanged(_e);
}
public boolean validate()
{
    boolean isValid;

    isValid = super();
    isValid = dimAccountController.validate() && isValid;

    return isValid;
}