web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

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

    You can do that by using chain of command

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    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,565 Moderator on at

    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

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

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    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

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

  • GirishS Profile Picture
    27,829 Moderator on at

    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

    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

    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,829 Moderator on at

    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…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 438 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 354 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans