Introduction: dynamic dialogs
This post shows how to make dynamic dialogs for Microsoft Dynamics AX reports. To illustrate this, I elaborated an example based on a standard Microsoft Dynamics AX report which can be found in the Human Resources module by following this path: Human Resources > Reports > Status lists > Absence status.
Purpose of this dynamic dialog is to fill in automatically the End date with a value equal to the end of the month of the entered value for the Start date.
Solution: dialogSelectCtrl method
Go to the class HRMAbsenceStatusListPrint, which is the class related to the Absence status report used in this example.
Add a new method called dialogSelectCtrl, which looks like this:
public void dialogSelectCtrl()
{
;
super();
// get the value entered by the
// end-user for the startDate
startDate = dialogStartDate.value();
// only set the a value if the endDate
// doesn’t have a value yet
if(startDate && !dialogEndDate.value())
{
// set automatically the endDate equal to the end
// of the month of the entered value by the end-user
dialogEndDate.value(EndMth(startDate));
}
}
Edit the existing dialog method and add following line just before the return dialog line to call the logic implemented in the dialogSelectCtrl method:
public Object dialog()
{
// call the dialogSelectCtrl method when a control is selected
dialog.allowUpdateOnSelectCtrl(true);
return dialog;
}
Very nice, thank you!
Post a Comment