Monday, 25 November 2013

Particular financial dimension mandatory on a form in AX 2012

We may come across mandate particular financial dimension on particular form.

Here is the process to mandate Department dimension for customers.

Am using event handlers introduced in AX 2012 to achieve this.
Go through the below link to understand better on Event handlers.

1.       Create a new Class with the name ‘CustTableEventHandler’

2.       Create a new Pre-or post-event handler method as shown below

3.       Rename newly created method as ‘custValidateWrite’ and write logic as shown below.

public static void custValidateWrite(XppPrePostArgs _args)
    DimensionAttribute                  dimAttr;
    DimensionAttributeValue             dimAttrValue;
    DimensionAttributeValueSetItem      dimAttrValueSetItem;
    CustTable                           custTable;
    RefRecId                            defaultDimension;
    boolean                             ret;

    custTable   = _args.getThis();
    ret         = _args.getReturnValue();

    defaultDimension    =   custTable.DefaultDimension;
    dimAttr             =   DimensionAttribute::findByName('Department');

    select firstonly RecId, DisplayValue from dimAttrValueSetItem
                where dimAttrValueSetItem.DimensionAttributeValueSet == defaultDimension
            join dimAttrValue
                where dimAttrValue.RecId == dimAttrValueSetItem.DimensionAttributeValue &&
                dimAttrValue.DimensionAttribute == dimAttr.RecId       &&
                dimAttrValue.IsDeleted == false;
    if (!dimAttrValueSetItem.DisplayValue)
        ret     = checkFailed("Department must be specified.");


4.       Go to ‘validateWrite’ method of CustTable then right click & select New event handler subscription as shown below.

5.       Go to the properties of newly created event handler method & set the properties as shown below.


6.       Now try to create new customer without department then it throws a message saying that ‘Department must be specified.’


  1. Hi Shankar,
    I followed your above steps but on creating a new Customer record I get "Internal error number 73 in script". Any ideas?

  2. Brilliant!! Worked well

  3. Hi Shankar, it's only warning notify , User can skip and without department, how to force user input department ? Thanks.

  4. Amazing. Solved my issue. My doubt is where else will this impact?

  5. Brilliant work! But my issue is it has the impact like for instance my requirement is to make the "Project" financial dimension as mandatory only on "Item Requirement" form of Project and Accounting module.
    Now since the Event Handler Subscription is on the ValidateWrite method of the SalesLine table, this "Project" dimension has become mandatory even on Sales Lines while I am creating Sales Order.

    Can't I simple make it mandatory on "Item Requirement" form?

  6. wow amazing, it's works, thank you very much :)

  7. Dear,

    I received message as internal error number 25 in scripts ax

    When I open the application i face this error,

    how to solve this issues.