Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How to override an active method for button disabling in a form in x++

(0) ShareShare
ReportReport
Posted on by 5

Hi,

I have a condition to disable few buttons until a record is created in that form. In order words, when the selects the existing record or when he creates a new record, the button should be visible or enable.

Consider the button names as open and close.

Thanks in advance.

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: How to override an active method for button disabling in a form in x++

    Hi, 

    I thing whole thread belongs D365 F&O forum, since bharat ram has tagged it as "Microsoft dynamics ax current version".

    Thanks,

    Girish S.

  • Mohit Rampal Profile Picture
    12,563 Moderator on at
    RE: How to override an active method for button disabling in a form in x++

    Hi, It seems your question was for D365 F&O and not for previous versions. Please move your post to D365 Finance Thread. community.dynamics.com/.../financeandoperations

    Also, you can use Chain of command to access controls directly if AutoDeclaration is set to Yes.

  • Suggested answer
    Komi Siabi Profile Picture
    12,903 Most Valuable Professional on at
    RE: How to override an active method for button disabling in a form in x++

    Ahan,

    The code Girish shared earlier works on custom form not standard one. I feel you asked your question on the wrong thread .

    For standard forms you need to use event handlers.

    community.dynamics.com/.../enable-disable-menu-item-button-on-a-form

  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator on at
    RE: How to override an active method for button disabling in a form in x++

    That's why you got this error. You can do extension either via coc or using onActivated event handler.

    Refer to the below blog.

    gvkkishore.wordpress.com/.../

    Thanks

    Girish S.

  • C4u Profile Picture
    70 on at
    RE: How to override an active method for button disabling in a form in x++

    Added in an extension class, from a standard one.

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: How to override an active method for button disabling in a form in x++

    Hi, 

    Where you have added this code?

    Thanks,

    Girish S.

  • C4u Profile Picture
    70 on at
    RE: How to override an active method for button disabling in a form in x++

    Yes, I have set the auto declaration to true but still I am facing those errors what I have mentioned earlier .

    Note: I am using an extension class of a standard model.

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: How to override an active method for button disabling in a form in x++

    Have you set the auto declaration property on the control to true on form properties.

    Also no need to declare datasource name. Just use the datasource name like if(TestGroup.Recid)

    Thanks,

    Girish S.

  • C4u Profile Picture
    70 on at
    RE: How to override an active method for button disabling in a form in x++

    This is the code I have tried to implement but got error at the places which are I mentioned in comments

    public int active()

    {

    TestGroup testgroup; // data source name

    int ret = super(); //Got error as super call not allowed here

    if(testgroup.RecId)

    {

    Open.enabled(true); //Open is the control name mentioned at form level for the button Open - Got error not found in scope

    Close.enabled(true); //Close is the control name mentioned at form level for the button Close - Got error not found in scope

    }

    else

    {

    Open.enabled(false);

    Close.enabled(false);

    }

    return ret;

    }

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: How to override an active method for button disabling in a form in x++

    Hi, 

    I have posted the full code.

    Can you show us the code where you have written and what error you got.

    Thanks

    Girish S.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 601 Most Valuable Professional

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 416

#3
Adis Profile Picture

Adis 384 Super User 2025 Season 1

Product updates

Dynamics 365 release plans