How to use default dimensions as Dialog fields in dialogs [Dynamics AX 2012]

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.

image

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.

image

If you use InitWithChecksAndValues method, your dialog looks like below

image

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.

 

Happy Dax6ng.

 

sree

Advertisements

One Response to “How to use default dimensions as Dialog fields in dialogs [Dynamics AX 2012]”

  1. vivek Says:

    Nice post Sir,

    But how about the extra dimensions which we add on Ax 2012 . How to get these dimensions in the dialog fields.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: