Friends,
This post will help you how to add default dimensions as dialog fields on the dialogs in AX 2012.
There is a new class that has been introduced in AX 2012 by name DialogFieldDimensionDefaultingController to handle this.
This class has been used in very few places in standard AX 2012 and is little tricky to pick the relevant code.
So this post will be handy for all developers at least at high level to get the default dimensions as dialog fields.
Below is the dialog with the default dimensions as dialog fields.
Code walkthrough:
Create a new class and methods as shown below one by one
class SR_DimensionDialog extends RunBase
{
#DimensionDefaultingFieldSetElements
DimensionAttributeValueSetStorage dimAttrValueSetStorage;
DialogFieldDimensionDefaultingController dfDimDefaultingControllerChecksAndValues;
DimensionDefaultingFieldSet dimensions;
Dialog dialog;
#DEFINE.CurrentVersion(1)
#LOCALMACRO.CurrentList
dimensions
#ENDMACRO
}
Object dialog()
{
dialog = super();
dialog.caption("DialogFieldDimensionDefaultingController example");
dfDimDefaultingControllerChecksAndValues = dialog.addDimensionDefaultingController();
//dfDimDefaultingControllerChecksAndValues.initWithChecksAndValues(false, false, false, true, 0, "Dimensions as dialog fields example", "@SYS104593");
dfDimDefaultingControllerChecksAndValues.initWithValues(false,false,true,0,"Dimension – dialog fields");
return dialog;
}
boolean getFromDialog()
{
dfDimDefaultingControllerChecksAndValues.save();
dimensions = dfDimDefaultingControllerChecksAndValues.value();
return super();
}
public container pack()
{
;
return [#CurrentVersion, #CurrentList];
}
void run()
{
// dimAttrValueSetStorage = DimensionAttributeValueSetStorage::find(Dimensions[#DimDefaultingFieldSet_AttrValueSetId]);
}
public boolean unpack(container packedClass)
{
boolean ret = false;
Version version = RunBase::getVersion(packedClass);
switch (version)
{
case #CurrentVersion:
[version, #CurrentList] = packedClass;
ret = true;
break;
}
return ret;
}
static void main(Args args)
{
SR_DefaultDimensionsDialog sr_DefaultDimensionsDialog;
sr_DefaultDimensionsDialog = new SR_DefaultDimensionsDialog();
if (SR_DefaultDimensionsDialog.prompt())
{
SR_DefaultDimensionsDialog.run();
}
}
Some more methods you can try in the DialogFieldDimensionDefaultingController class are shown below.
I have used initWithValues as I am interested in only capturing the dialog values.
If you use InitWithChecksAndValues method, your dialog looks like below
However you need to write additional code to make it work though.
Explore the other methods based on your requirements.
That’s all for now.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.