My 2p about ERP Solutions, Information Worker Solutions and other software products (mainly Microsoft Dynamics AX and Microsoft SharePoint).

22 February 2009

X++ Code Snippet: disabling form elements

by Patrik Luca 4 comments


This X++ Code Snippet post will describe how you can disable a form element, based on the value of another form element.

As example, the CustTable form will be used. The example will disable the One-time customer checkbox on the General tab if the Mandatory credit limit checkbox is checked on the same General tab.

Step 1: Change some form properties

  1. Select the Administration Field Group on the TabGeneral TabPage and set the AutoDataGroup Property to No.
  2. Select the Administration_OneTimeCustomer CheckBox field in the Field Group Administration and set the AutoDeclaration property to Yes.

Step 2: Create a form method to enable/disable the form element

Create a new form method setAccessOneTimeCustomer:

void setAccesssOneTimeCustomer()     

    if (CustTable.MandatoryCreditLimit)





Step 3: call the form method in the active and the modified

Call the newly created form method in the active method on the Data Source of the Form. As such, the second field will be enabled or disabled appropriately upon scrolling through the form.

public int active() 

    int ret;


    ret = super();

    return ret;


Call the newly created form method in the modified method on the field which should trigger the enabling or disabling. In our example, it is the field MandatoryCreditLimit. As such the second field, in our case OneTimeCustomer wil be enabled or disabled each time the value of MandatoryCreditLimit is changed.

public void modified()   



Step 4: Test your modifications

Open the CustTable form: check the field Mandatory credit limit: the field One-time customer will be disabled immediately.

Comments 4 comments
Anonymous said...

Hey, this is a really great article for AX developers. Well done here.

Minh said...

Nice post, this helped me a lot!

Anonymous said...

Sorry if this is so simeple but do we have a get lase value of element or .last()?

Basically I am selected all data and have the header in one programmable area and the department in another programable area and need it to place all information under that header.


if ( (gpcFTEREport.dept[1]) == gpcFTEREport.dept[1])

if (PDN == TRUE)
PDN = false;
if (PDN == false)
PDN = false;

Siddharth said...

Thanks a lot for this, it really helped me!

Patrik Luca, Ieper, BELGIUM
Feel free to use or spread all of the content on my blog. In return, linking back to my blog would be greatly appreciated. All my posts and articles are provided "AS IS" with no warranties.

Subscribe feeds via e-mail
Subscribe in your preferred RSS reader

Subscribe feeds rss Most Read Entries

Subscribe feeds rss Recent Entries


Recommended Books

Subscribe feeds rss Recent Comments

This Blog is part of the U Comment I Follow movement in blogosphere. Means the comment field of this blog is made DOFOLLOW. Spam wont be tolerated.

Blog Archive

My Blog List