This
article explains about:
·
In
Microsoft Dynamics AX 2012 how to get account lookup based on account type.
·
In
Microsoft Dynamics AX 2012 how to get account lookup based on Ledger Account
type, Bank Account type, Customer Account type, Vendor Account type etc.
Applied on: Dynamics AX 2012 R3 CU8.
Prerequisite: Basic Dynamics AX 2012 programming knowledge.
Target audience: AX programmers.
Assumption: You are familiar with Dynamics AX 2012.
Prerequisite: Basic Dynamics AX 2012 programming knowledge.
Target audience: AX programmers.
Assumption: You are familiar with Dynamics AX 2012.
In Microsoft
Dynamics AX 2012 Account lookup works in a different way because dimension
structure change in comparison with Microsoft Dynamics AX 2009.
Below
are some screenshots which give an idea what output we are going to achieve.
A new
table created with two fields e.g. Account type (LedgerJournalACType) and
Account (LedgerDimensionAccount). The relation comes with the EDT when you drag
and drop the EDT to this table fields to create a new field.
Sample output of Ledger account type. When you select
Ledger it gives the segment option as well.
Sample output of Customer account type.
A new form created with two fields e.g. Account type and
Account. These are bound fields. Above table has been used as data source for
this form. Field Account (LedgerDimensionAccount) at form data source has two
methods called jumpRef() and resolveReference().
JumpRef() code:
public void jumpRef()
{
dimOnlinePaymController.jumpRef();
}
ResolveReference() code:
public Common
resolveReference(FormReferenceControl _formReferenceControl)
{
Common common =
dimOnlinePaymController.resolveReference();
return
common;
}
We have few more methods at form control level. For
Account field as control we need to take a segment entity control which should
be bounded to data source field called LedgerDimensionAccount. You can get this
control by right click on form design or field group or wherever you want.
On below screenshot we have a segment entry control and
it has 6 methods. Code for all these methods I mentioned here in this article.
The auto declare property of this control is set to Yes.
Declaration at form level:
public class FormRun extends
ObjectRun
{
DimensionDynamicAccountController dimOnlinePaymController;
}
Form init():
public void init()
{
super();
dimOnlinePaymController =
DimensionDynamicAccountController::construct(RBAccountTypeLookup_DS, fieldStr(RBAccountTypeLookup,
LedgerDimensionAccount), fieldStr(RBAccountTypeLookup,
LedgerJournalACType));
dimOnlinePaymController.parmIsDefaultAccount(true);
}
Method at form control level:
public void jumpRef()
{
dimOnlinePaymController.jumpRef();
}
public Common
resolveReference(FormReferenceControl _formReferenceControl)
{
Common common = dimOnlinePaymController.resolveReference();
return
common;
}
Method at form control level:
public void jumpRef()
{
dimOnlinePaymController.jumpRef();
}
Method at form control level:
public void
loadAutoCompleteData(LoadAutoCompleteDataEventArgs _e)
{
super(_e);
dimOnlinePaymController.loadAutoCompleteData(_e);
}
Method at form control level:
public void loadSegments()
{
super();
dimOnlinePaymController.parmControl(this);
dimOnlinePaymController.loadSegments();
}
Method at form control level:
public void lookup()
{
switch
(RBAccountTypeLookup.LedgerJournalACType)
{
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;
}
}
Method at form control level:
public void segmentValueChanged(SegmentValueChangedEventArgs
_e)
{
super(_e);
dimOnlinePaymController.segmentValueChanged(_e);
}
Method at form control level:
public boolean validate()
{
boolean
isValid;
isValid = super();
isValid =
dimOnlinePaymController.validate() && isValid;
return
isValid;
}
Save your work and try to run the form.
The above code is available in Microsoft Dynamics AX
2012. Only thing I did is assembled the required code here to make is handy.
Hope this was useful for you. Feel free to leave your comments below.
No comments:
Post a Comment