Check it out here: http://www.microsoft.com/dynamics/ax/erd/ax2012r2/
Ex: ERD: Centered on table 'GeneralJournalAccountEntry'
Sequence of methods in form and table in AX
Form:
Sequence of Methods calls while opening the Form
Form — init ()
Form — Datasource — init ()
Form — run ()
Form — Datasource — execute Query ()
Form — Datasource — active ()
Sequence of Methods calls while closing the Form
Form — canClose ()
Form — close ()
Sequence of Methods calls while creating the record in the Form
Form — Datasource — create ()
Form — Datasource — initValue ()
Table — initValue ()
Form — Datasource — active ()
Sequence of Method calls while saving the record in the Form
Form — Datasource — ValidateWrite ()
Table — ValidateWrite ()
Form — Datasource — write ()
Table — insert ()
Sequence of Method calls while deleting the record in the Form
Form — Datasource — validatedelete ()
Table — validatedelete ()
Table — delete ()
Form — Datasource — active ()
Sequence of Methods calls while modifying the fields in the Form
Table — validateField ()
Table — modifiedField ()
Table:
When you press CTR+NinitValue()->
When you change data in a field
validateField() -> validateFieldValue() -> ModifiedField() -> ModifiedFieldValue()
When you close the table after entering some data
validateWrite() – > Insert() -> aosValidateInsert()
When you Save the Record for the first time
validateWrite() ->Insert() – > aosValidateInsert()
When you modify the record and saving
validateWrite() -> update() – > aosValidateUpdate()
When you delete the record
validateDelete() -> delete() -> aosValidateDelete()
Nhãn:
AX 2009,
AX 2012,
Sequence of methods
How to create multi-select lookup dialog for class in AX 2012
Create these methods in your class:
class DICPromotion2SalesLine extends Runbase
{
DialogRunbase dialog;
DialogGroup dialogGrp;
FormBuildStringControl fbsCtrlPromotion;
FormStringControl fsCtrlPromotion;
container returnPromotion;
SysLookupMultiSelectCtrl msCtrlPromotion;
str promotionRange;
}
protected Object dialog()
{
FormBuildControl setupGroupControl;
;
dialog = super();
dialog.alwaysOnTop(true);
dialog.windowType(FormWindowType::Standard);
dialogGrp = dialog.addGroup('Promotion');
setupGroupControl = dialog.formBuildDesign().control(dialogGrp.formBuildGroup().id());
fbsCtrlPromotion = setupGroupControl.addControl(FormControlType::String, identifierstr(DICPromotionID));
fbsCtrlPromotion.label('Promotion id');
dialog.allowUpdateOnSelectCtrl(true);
this.dialogSelectCtrl();
return dialog;
}
public void dialogPostRun(DialogRunbase _dialog)
{
FormRun formRun;
super(dialog);
formRun = _dialog.dialogForm().formRun();
if (formRun)
{
fsCtrlPromotion = formRun.design().control(fbsCtrlPromotion.id());
/// you can build with your own query, or created query in system by method construct
msCtrlPromotion = SysLookupMultiSelectCtrl::constructWithQuery(formRun, fsCtrlPromotion, this.buildQuery());
}
}
// build your Query here
public query buildQuery()
{
Query q = new Query();
QueryBuildDataSource qbds;
DICTmpPromotionTable tmpPromotionTable;
;
qbds = q.addDataSource(tablenum(DICPromotionMaster));
qbds.addSelectionField(fieldNum(DICPromotionMaster, PromotionID));
qbds.addSelectionField(fieldNum(DICPromotionMaster, Description));
qbds.addSelectionField(fieldNum(DICPromotionMaster, WithGroupItem));
qbds.addSelectionField(fieldNum(DICPromotionMaster, Fromdate));
qbds.addSelectionField(fieldNum(DICPromotionMaster, ToDate));
tmpPromotionTable = this.searchPromotion();
while select tmpPromotionTable
{
qbds.addRange(fieldNum(DICPromotionMaster,PromotionID)).value(tmpPromotionTable.PromotionID);
}
return q;
}
public boolean getFromDialog()
{
boolean ret;
#Characters
ret = super();
if (msCtrlPromotion)
{
returnPromotion = msCtrlPromotion.getSelectedFieldValues(); // get actual value of the selected rows
returnPeriodRecId = msCtrlPromotion.get(); // get RecIds of the selected rows (it's very useful when you want to look one field and return another field value)
returnPeriodRecId = msCtrlPromotion.get(); // get RecIds of the selected rows (it's very useful when you want to look one field and return another field value)
}
promotionRange = con2StrUnlimited(returnPromotion,#comma);
return ret;
}
How to create form with Display Inventory Dimensions in AX 2012 with X++
Create a table with fields: ItemId, InventdimId
Add these methods to your Form :
public class FormRun extends ObjectRun
{
InventDimCtrl_Frm_EditDimensions inventDimFormSetup;
}
public void init()
{
super();
element.updateDesign(InventDimFormDesignUpdate::Init);
}
Object inventDimSetupObject()
{
return inventDimFormSetup;
}
void updateDesign(InventDimFormDesignUpdate mode)
{
switch (mode)
{
case InventDimFormDesignUpdate::Init :
if (!inventDimFormSetup)
{
inventDimFormSetup = InventDimCtrl_Frm_EditDimensions::newFromForm(element);
}
//inventDimFormSetup.parmSkipOnHandLookUp(true);
case InventDimFormDesignUpdate::Active :
//allow choosing dimension
inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(DICPromotionAmountItem.ItemId));
inventDimFormSetup.formSetControls(true);
break;
case InventDimFormDesignUpdate::FieldChange :
inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(DICPromotionAmountItem.ItemId));
InventDim_PromotionAmountItem.clearNotSelectedDim(inventDimFormSetup.parmDimParmEnabled());
inventDimFormSetup.formSetControls(true);
break;
default : throw error(strFmt("@SYS54195",funcName()));
}
}
Override these methods in Form>>Datasource.
public boolean validateWrite()
{
boolean ret;
DICPromotionAmountItem.InventDimId = InventDim::findOrCreate(InventDim_PromotionAmountItem).InventDimId;
ret = super();
return ret;
}
public int active()
{
int ret;
;
ret = super();
element.updateDesign(InventDimFormDesignUpdate::Active);
return ret;
}
public void modified()
{
;
super();
element.updateDesign(
InventDimFormDesignUpdate::FieldChange);
inventDim.clearNotSelectedDim(element.inventDimSetupObject().parmDimParmEnabled());
}
Override method modified for ItemId field in your datasource
public void modified()
{
;
super();
element.updateDesign(InventDimFormDesignUpdate::FieldChange);
InventDim_PromotionAmountItem.clearNotSelectedDim(element.inventDimSetupObject().parmDimParmEnabled());
}
In Action Pane >> create a new menuitembutton set bellow the propertitys
Caption : DisplayDimensions
Menuitemtype : display
MenuItemName : InventDimParmFixed
Add these methods to your Form :
public class FormRun extends ObjectRun
{
InventDimCtrl_Frm_EditDimensions inventDimFormSetup;
}
public void init()
{
super();
element.updateDesign(InventDimFormDesignUpdate::Init);
}
Object inventDimSetupObject()
{
return inventDimFormSetup;
}
void updateDesign(InventDimFormDesignUpdate mode)
{
switch (mode)
{
case InventDimFormDesignUpdate::Init :
if (!inventDimFormSetup)
{
inventDimFormSetup = InventDimCtrl_Frm_EditDimensions::newFromForm(element);
}
//inventDimFormSetup.parmSkipOnHandLookUp(true);
case InventDimFormDesignUpdate::Active :
//allow choosing dimension
inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(DICPromotionAmountItem.ItemId));
inventDimFormSetup.formSetControls(true);
break;
case InventDimFormDesignUpdate::FieldChange :
inventDimFormSetup.formActiveSetup(InventDimGroupSetup::newItemId(DICPromotionAmountItem.ItemId));
InventDim_PromotionAmountItem.clearNotSelectedDim(inventDimFormSetup.parmDimParmEnabled());
inventDimFormSetup.formSetControls(true);
break;
default : throw error(strFmt("@SYS54195",funcName()));
}
}
Override these methods in Form>>Datasource.
public boolean validateWrite()
{
boolean ret;
DICPromotionAmountItem.InventDimId = InventDim::findOrCreate(InventDim_PromotionAmountItem).InventDimId;
ret = super();
return ret;
}
public int active()
{
int ret;
;
ret = super();
element.updateDesign(InventDimFormDesignUpdate::Active);
return ret;
}
public void modified()
{
;
super();
element.updateDesign(
InventDimFormDesignUpdate::FieldChange);
inventDim.clearNotSelectedDim(element.inventDimSetupObject().parmDimParmEnabled());
}
Override method modified for ItemId field in your datasource
public void modified()
{
;
super();
element.updateDesign(InventDimFormDesignUpdate::FieldChange);
InventDim_PromotionAmountItem.clearNotSelectedDim(element.inventDimSetupObject().parmDimParmEnabled());
}
In Action Pane >> create a new menuitembutton set bellow the propertitys
Caption : DisplayDimensions
Menuitemtype : display
MenuItemName : InventDimParmFixed
Convert row, column to Excel range in Axapta
This method is show how to convert row and column to Excel range:
rowfrom = 1,
colfrom = 1,
rowto = 5,
colto = 5;
>> A1:E5
public str convertToRange(int rowfrom, int colfrom, int rowto = 0,int colto = 0)
{
str strrange, srange1;
;
if(rowfrom <= 0 || colfrom <= 0)
{
throw warning("We don`t have row <=0 or column <=0 in Excel");
}
if(rowto != 0 && colto != 0)
{
if(rowto <= 0 || colto <= 0)
{
throw warning("We don`t have row <=0 or column <=0 in Excel");
}
if(colto <= 26)
{
strrange = num2char(colto+64) + int2str(rowto);
}
else
{
strrange = num2char((colto-1)/26+64)+num2char(((colto-1)mod 26)+65) + int2str(rowto);
}
}
if(colfrom <= 26)
{
srange1 = num2char(colfrom+64) + int2str(rowfrom);
}
else
{
srange1=num2char((colfrom-1)/26+64)+num2char(((colfrom-1)mod 26)+65) + int2str(rowfrom);
}
if(rowto != 0 && colto != 0)
{
return srange1 + ":" + strrange;
}
else return srange1;
}
rowfrom = 1,
colfrom = 1,
rowto = 5,
colto = 5;
>> A1:E5
public str convertToRange(int rowfrom, int colfrom, int rowto = 0,int colto = 0)
{
str strrange, srange1;
;
if(rowfrom <= 0 || colfrom <= 0)
{
throw warning("We don`t have row <=0 or column <=0 in Excel");
}
if(rowto != 0 && colto != 0)
{
if(rowto <= 0 || colto <= 0)
{
throw warning("We don`t have row <=0 or column <=0 in Excel");
}
if(colto <= 26)
{
strrange = num2char(colto+64) + int2str(rowto);
}
else
{
strrange = num2char((colto-1)/26+64)+num2char(((colto-1)mod 26)+65) + int2str(rowto);
}
}
if(colfrom <= 26)
{
srange1 = num2char(colfrom+64) + int2str(rowfrom);
}
else
{
srange1=num2char((colfrom-1)/26+64)+num2char(((colfrom-1)mod 26)+65) + int2str(rowfrom);
}
if(rowto != 0 && colto != 0)
{
return srange1 + ":" + strrange;
}
else return srange1;
}
Subscribe to:
Posts (Atom)



