Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / How to disable sales t...
Finance forum

How to disable sales table button in action pane in D365FO

(0) ShareShare
ReportReport
Posted on by 630

Hi friends,

In sales table form in action pane i created new button i want to disable the button.
Please tell me how to disable the button.

Note: I want when we click on new created button it will be disable automatically.  

Thanks & Regards,

Rahul.

  • Rahul.p Profile Picture
    630 on at
    RE: How to disable sales table button in action pane in D365FO

    Thanks Nikolaos, Working.

  • Blue Wang Profile Picture
    on at
    RE: How to disable sales table button in action pane in D365FO

    Hi Rahul.p,


    Here's an example about how to add new button to existing form in new Dynamics AX and disable or enable it based on condition.
    https://meritsolutions.com/disable-enable-button-dynamics-ax/

    Create_2D00_button_2D00_Dynamics_2D00_AX_2D00_940x460_2D00_1.png

    I hope it will help you.

  • Verified answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: How to disable sales table button in action pane in D365FO

    You should put this code in the onActivated method of SalesTable data source. Then it will check the condition every time a new SalesTable record is selected, and updates the "enabled" accordingly.

    If it's in CreateInvoice_OnClicked it's only executed when somebody clicks that button.

            FormRun formRun                = sender.formRun();
            FormDesign formDesign = formRun.design();
    	FormButtonControl Z_CreateInvoice = formDesign.controlname(formControlStrSalesTable, Z_CreateInvoice as FormButtonControl;
            SalesTable salesTable = formRun.dataSource(0).cursor() as SalesTable;
    
    
            Z_CreateInvoice.enabled(salesTable.SalesStatus == SalesStatus::Invoiced);
  • Rahul.p Profile Picture
    630 on at
    RE: How to disable sales table button in action pane in D365FO

    Please check my event handler.

        [FormControlEventHandler(formControlStr(SalesTable, Z_CreateInvoice), FormControlEventType::Clicked)]
        public static void Z_CreateInvoice_OnClicked(FormControl sender, FormControlEventArgs e)
        {
            FormRun          formrun                = sender.formRun();
            FormDesign formDesign = formrun.design();
            SalesTable salesTable = sender.formRun().dataSource(0).cursor() as SalesTable;
    
            if(salesTable.SalesStatus == SalesStatus::Invoiced)
            {
                Z_CreateInvoice.enable(true);
            }
        }

    I want if salessataus is invoiced then button should be disable.

  • Suggested answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: How to disable sales table button in action pane in D365FO

    It depends of your code.

    If you have an event handler you can get it like this (if it's not a string you can't use FormStringControl, instead the correct control type):

    FormDesign formDesign = formRun.design(); // You can get FormRun from the event handler parameters
    
    FormStringControl MyField = formDesign.controlName(formControlStr(SalesTable, MyField)) as FormStringControl;
    
    MyField.enabled(false);

    If you still have issues please share your code. We need to see if it's an event handler, CoC or something else.

  • Rahul.p Profile Picture
    630 on at
    RE: How to disable sales table button in action pane in D365FO

    I set button AutoDeclaration property to true

    I wrote code like MyButton.enabled(true);

    But error is coming "Variable 'MyButton' is not found in scope."

    Please tell me how to declare it.

  • Suggested answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: How to disable sales table button in action pane in D365FO

    Seems you ended up in the Dynamics AX forum. I have moved your post to D365FO forum.

    You have some options.

    1) Set property Enabled to false in the button properties. This is only feasible if you don't have any additional requirements (we don't know since no additional details were shared).

    2) Set your button's AutoDeclaration property to true, and then in x++ code call MyButton.enabled(false) whenever you want to disable the button, or MyButton.enabled(true) when you want to enable it.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,272 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,931 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans