web
You’re offline. This is a read only version of the page.
close
Skip to main content
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 70

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 the user creates a new record, the button should be visible or enable.

Consider the button names as open and close.

Thanks.

I have the same question (0)
  • brianmaric Profile Picture
    on at
    RE: How to override an active method for button disabling in a form in x++

    You can do that by using chain of command

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    RE: How to override an active method for button disabling in a form in x++

    Write COC for both init and active methods. Init method when you open the form until selecting any record. Active, when record selected.

  • Suggested answer
    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, There is another thread for exactly same requirement. Probably you have duplicated it. If not, then please check this thread and follow the suggestions

    community.dynamics.com/.../how-to-override-an-active-method-for-button-disabling-in-a-form-in-x

    If still issues, please let us know.

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

    Can you help me with the sample code for these 2 methods ?

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

    If your requirement is on a custom form then you don't need CoC or event Handler as you can directly override those form methods. However, if it's a standard form then please check this article

    https://wp.me/p5srMU-dM

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

    This article shows the event handler right, can you provide inputs over coc ?

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

    Hi,

    Refer to the below blog for using active method with COC.

    http://axaptaworld-saklani.blogspot.com/2021/01/d365-f-call-active-method-through.html

    Thanks,

    Girish S.

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

    I am getting quite a lot of error. Whether this method can be written in a class where the first line is extensionof(tablestr("Specific data source name")). Can you provide me a sample code of lines for this active method ?.

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    RE: How to override an active method for button disabling in a form in x++

    If you want to write the extension of active, you need to write it as formdatasourcestr as the method is found at form datasource level. You cannot find this method at table level. You can simply follow the link which Girish shared.

  • 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++

    Refer to the below code.

    [ExtensionOf(formdatasourcestr(FornName, DataSourceName))] // Extension of Standard Obejct
    final class ClassName_Extension
    {
        public int Active()
        {
            int             ret;
            ret = next Active(); 
            TableName   tableName   =  element.tableName; 
            if(tableName)
            {
                buttonname.enabled(true);
            }
            else
            {
                buttonname.enabled(false);
            }
            return ret;
        }
    }

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,028

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 878 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 579 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans