Thursday, May 24, 2012

Steps to Implement Default Account in Dynamics ax 2012.


Create a new Table in the AOT and name it for example SampleDimensionPattern.
2. Add a new field in the SampleDimensionPattern table of type Int64 and name it ExpenseLedgerDimension and specify the EDT on that field as LedgerDimensionDefaultAccount
3. Add a new form under form node in the AOT and name it as TutorialDefaultAccountForm
4. Add/ Drag the table SampleDimensinPattern to the datasource node of the form.
5. Right mouse click on the TabPage:TabDefaultAccount node and select New Control -> SegmentedEntry from the list.  This creates a new Segmented Entry control that we can now specialize to handle default accounts.
6. Highlight the node SegmentedEntry:SegmentedEntry and change the Name, DataSource and ReferenceField properties to ExpenseLedgerDimension, SampleDimensionPatterns and ExpenseLedgerDimension.
7. Place the following code in Declaration area of the form
public class FormRun extends ObjectRun
{   LedgerDimensionDefaultAccountController ledgerDimensionDefaultAccountController;
}
8. In the Init method add below code
public void init()
{
   super();
   ledgerDimensionDefaultAccountController =
   LedgerDimensionDefaultAccountController::construct(SampleDimensionPatterns_ds,
          fieldstr(SampleDimensionPatterns, ExpenseLedgerDimension));
}
9. Overload the following methods on the method of new Segmented entry control that is added in step 6
jumpRef
public void jumpRef()
{
ledgerDimensionDefaultAccountController.jumpRef();
}
loadAutoCompleteData
public void loadAutoCompleteData(LoadAutoCompleteDataEventArgs _e)
{
super(_e);
ledgerDimensionDefaultAccountController.loadAutoCompleteData(_e);
}
segmentValueChanged
public void segmentValueChanged(SegmentValueChangedEventArgs _e)
{
super(_e);
ledgerDimensionDefaultAccountController.segmentValueChanged(_e);
}
loadSegments
public void loadSegments()
{
super();
ledgerDimensionDefaultAccountController.parmControl(this);
ledgerDimensionDefaultAccountController.loadSegments();
}
 validate
public boolean validate()
{
boolean isValid;
isValid = super();
isValid = ledgerDimensionDefaultAccountController.validate() && isValid;
return isValid;
}
10. Overload the resolveReference method in the method node of the datasource field “ExpenseLedgerDimension”.
public Common resolveReference(FormReferenceControl _formReferenceControl)
{
    return ledgerDimensionDefaultAccountController.resolveReference();
}

No comments:

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...