INDEX :
1) Dialog Demo
2) Data Filteration in dialog box in Microsoft Dynamics AX.
3) NO Yes Box
4) Browser button to create and select file at particular folder
5) Code to filter only CSV and Excel files
6) How to Pass arguments to Dialog
7) How to make Dialog Fields Mandatory
8) Get Lookup Based on other field selected value in dialog
========================================================================
1) Create a
EDT name it Gender then in properties enumType : //select the enum name
1) Dialog Demo
2) Data Filteration in dialog box in Microsoft Dynamics AX.
3) NO Yes Box
4) Browser button to create and select file at particular folder
5) Code to filter only CSV and Excel files
6) How to Pass arguments to Dialog
7) How to make Dialog Fields Mandatory
8) Get Lookup Based on other field selected value in dialog
========================================================================
The application class Dialog is used to build dialogs. Other application classes, such as DialogField, DialogGroup, DialogTabPage, and others, are used to create dialog controls. A common way of using dialogs is within the RunBase framework classes, where user input is required.
static void
Simple_Dialog (Args _args)
{
dialog dialog;
dialogGroup dialogGroup;
dialogField dialogField;
dialog = new
Dialog("Simple Dialog");
dialogField = dialog.addField(extendedTypeStr(Gender));
if (dialog.run())
{
print dialogField.value();
pause;
}
}
OR
TRY Below
static void CreateRadio(Args _args)
{
Dialog dialog = new Dialog();
DialogField dialogField;
FormRadioControl formRadioControl;
;
dialogField = dialog.addField(EnumStr(Sex));
//instead of Sex give your enum name
formRadioControl = dialogField.control();
formRadioControl.helpText("Sample Dialog");
dialog.run();
}
or
To run Code based on YEs and No condition : static void JobBoxDemo(Args _args)
{
DialogButton diagBut;
str strMessage = "The No button should have initial focus.";
str strTitle = "Title";
;
diagBut = Box::yesNoCancel(
strMessage,
DialogButton::No, // Initial focus is on the No button.
strTitle);
if (diagBut == DialogButton::No)
{
print "The No button was clicked.";
}
else
{
print "The button that was clicked was: ", diagBut;
}
pause; // brings msg box, do you want to continue or not
}
========================================================================
;
db = box::yesNo("Choose Yes or No", dialogButton::Yes, "Yes
No Box Example");
if (db == dialogButton::Yes)
{
info( "We chose Yes");
}
else
if (db == dialogButton::No)
{
info( "We chose No");
}
=====================================================================
4)
Dialog dialog;
DialogField fieldfilename;
;
dialog = new Dialog("My Dialog");
dialog.addText("Select your favorite customer:");
fieldfilename;= dialog.addField(extendedTypeStr(FilenameSave));
dialog.run();
if (dialog.closedOk())
{
info(fieldfilename;.value());
}
For File Open - Use "FilenameOpen " - EDT
For File Save - Use " FilenameSave" - EDT
=====================================================================
5) Code to filter only csv and excel files
public Object dialog()
{
DialogRunbase dialog = super();
#AviFiles
#Excel
dialogFilename = dialog.addField(typeId(FilenameOpen));
dialog.filenameLookupFilter(["@SYS28576",#XLSX,"@SYS100852","*.csv"]);
dialog.filenameLookupTitle("Upload from EXCEL/CSV");
dialogFilename.value(filename);
return dialog;
}
====================================================================
6) How to Pass arguments to Dialog :
http://microsoft-dynamics-ax-erp.blogspot.in/2012/09/how-to-pass-value-from-menuitembutton.html
========================================================================
How to make dialog fields mandatory
See example below on how implement mandatory fields in dialog:
boolean ret;
FilePath workFolder;
Dialog dlg;
DialogField dfWorkFolder;
FormStringControl fsc;
FormGroupControl fgc;
;
dlg = new Dialog( "@CDT135" );
dfWorkFolder = dlg.addField( typeid( FilePath ), "@CDT136" );
fgc = dlg.mainFormGroup();
fsc = fgc.controlNum( 1 ); fsc.mandatory( true );
while( dlg.run() )
{
workFolder = dfWorkFolder.value();
if( workFolder)
{
ret = true;
break;
}
dlg.doInit();
}
========================================================================
8) Get Lookup Based on other field selected value in dialog
TRY Below
static void CreateRadio(Args _args)
{
Dialog dialog = new Dialog();
DialogField dialogField;
FormRadioControl formRadioControl;
;
dialogField = dialog.addField(EnumStr(Sex));
//instead of Sex give your enum name
formRadioControl = dialogField.control();
formRadioControl.helpText("Sample Dialog");
dialog.run();
}
or
To run Code based on YEs and No condition : static void JobBoxDemo(Args _args)
{
DialogButton diagBut;
str strMessage = "The No button should have initial focus.";
str strTitle = "Title";
;
diagBut = Box::yesNoCancel(
strMessage,
DialogButton::No, // Initial focus is on the No button.
strTitle);
if (diagBut == DialogButton::No)
{
print "The No button was clicked.";
}
else
{
print "The button that was clicked was: ", diagBut;
}
pause; // brings msg box, do you want to continue or not
}
========================================================================
2) Data filtration in dialog box In Microsoft Dynamics AX
public class CustAmountCalculation extends RunBase
{
DialogField fieldAccount;
CustAccount custAccount;
}
public Object dialog()
{
Dialog dialog;
DialogGroup groupCustomer;
dialog = super();
fieldAccount = dialog.addField(extendedTypeStr(custAccount), "CustomerAccount");
return dialog;
}
public boolean getFromDialog()
{
custAccount = fieldAccount.value();
return super();
}
public container pack()
{
return conNull();
}
public void run()
{
CustTable custTable;
CustTrans custTrans;
;
select sum(AmountMST) from custTrans where custTrans.AccountNum == custAccount;
info("You have enetered customer information");
info(strfmt("Account: %1", custAccount));
info(strFmt("Amount: %1", custTrans.AmountMST));
}
public boolean unpack(container _packedClass)
{
return true;
}
public static void main(Args _args)
{
CustAmountCalculation custAmountCalculation = new CustAmountCalculation();
if (CustAmountCalculation.prompt())
{
CustAmountCalculation.run();
}
}
==================================================================
3)
Dialogbutton db;;
db = box::yesNo("Choose Yes or No", dialogButton::Yes, "Yes
No Box Example");
if (db == dialogButton::Yes)
{
info( "We chose Yes");
}
else
if (db == dialogButton::No)
{
info( "We chose No");
}
=====================================================================
4)
Dialog dialog;
DialogField fieldfilename;
;
dialog = new Dialog("My Dialog");
dialog.addText("Select your favorite customer:");
fieldfilename;= dialog.addField(extendedTypeStr(FilenameSave));
dialog.run();
if (dialog.closedOk())
{
info(fieldfilename;.value());
}
For File Open - Use "FilenameOpen " - EDT
For File Save - Use " FilenameSave" - EDT
=====================================================================
5) Code to filter only csv and excel files
public Object dialog()
{
DialogRunbase dialog = super();
#AviFiles
#Excel
dialogFilename = dialog.addField(typeId(FilenameOpen));
dialog.filenameLookupFilter(["@SYS28576",#XLSX,"@SYS100852","*.csv"]);
dialog.filenameLookupTitle("Upload from EXCEL/CSV");
dialogFilename.value(filename);
return dialog;
}
====================================================================
6) How to Pass arguments to Dialog :
http://microsoft-dynamics-ax-erp.blogspot.in/2012/09/how-to-pass-value-from-menuitembutton.html
========================================================================
How to make dialog fields mandatory
See example below on how implement mandatory fields in dialog:
boolean ret;
FilePath workFolder;
Dialog dlg;
DialogField dfWorkFolder;
FormStringControl fsc;
FormGroupControl fgc;
;
dlg = new Dialog( "@CDT135" );
dfWorkFolder = dlg.addField( typeid( FilePath ), "@CDT136" );
fgc = dlg.mainFormGroup();
fsc = fgc.controlNum( 1 ); fsc.mandatory( true );
while( dlg.run() )
{
workFolder = dfWorkFolder.value();
if( workFolder)
{
ret = true;
break;
}
dlg.doInit();
}
========================================================================
8) Get Lookup Based on other field selected value in dialog
class Lookupx extends RunBase
{
TreeNode treeNode;
UtilElements utilElements;
UtilEntryLevel utilLevel;
ModelName name;
str
value1;
DialogRunbase dialog;
DialogField dialogField;
DialogField dialogFieldModel;
}
|
public object Dialog()
{
FormStringControl control;
dialog = super();
dialog.caption("Select
Layer");
dialogField = dialog.addField(enumStr(UtilEntryLevel),"Select Layer");
dialogFieldModel= dialog.addField(extendedtypestr(ModelName));
control = dialogFieldModel.control();
control.registerOverrideMethod(methodStr(FormStringControl,lookup),methodStr(Har_LayerObjectCount,nameLookup),this);
return
dialog;
}
|
public boolean
getFromDialog()
{
boolean
ret;
utilLevel =
dialogField.value();
name =
dialogFieldModel.value();
value1 = any2str(utilLevel);
ret =
super();
return
ret;
}
|
private void
nameLookup(FormControl _control)
{
SysTableLookup sysTableLookup;
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange nameQBR;
Query query = new
Query();
queryBuildDataSource =
Query.addDataSource(tableNum(UtilModels));
sysTableLookup = SysTableLookup::newParameters(tableNum(UtilModels), _control,true);
sysTableLookup.addLookupfield(fieldNum(UtilModels, Name), true);
sysTableLookup.addLookupfield(fieldNum(UtilModels, publisher), true);
nameQBR = queryBuildDataSource.addRange(fieldnum(UtilModels,
Layer));
//nameQBR.value(value1);
nameQBR.value(queryValue(DialogField.value()));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
|
public void
run()
{
UtilModels utilModels;
TreeNode childNode;
#Properties
int
tableCount = 0;
int
classCount = 0;
int
formCount = 0;
while
select * from utilElements
where
utilElements.utilLevel == utilLevel
&&
(utilElements.recordType ==
UtilElementType::Table
|| utilElements.recordType ==
UtilElementType::Class
|| utilElements.recordType ==
UtilElementType::Form)
{
treeNode = xUtilElements::getNodeInTree(utilElements);
if(SysTreeNode::existsInLayer(treeNode,
utilLevel))
{
if(utilElements.recordType == UtilElementType::Table)
{
tableCount++;
}
else
if (utilElements.recordType ==
UtilElementType::Class)
{
classCount++;
}
else
if (utilElements.recordType ==
UtilElementType::Form)
{
formCount++;
}
}
}
info(strFmt("No of Tables
: %1 ",
tableCount));
info(strFmt("No of Classes
: %1 ",
classCount));
info(strFmt("No of Forms
: %1 ",
formCount));
}
|
public static
void main(Args _args)
{
Lookupx layerObjectCount = new Lookupx();
if(layerObjectCount.prompt())
{
layerObjectCount.run();
}
}
|
public boolean
layerModified(FormStringControl _control)
{
dialogFieldModel.value(_control.valueStr());
return
true;
}
|
No comments:
Post a Comment