Skip to main content



No record found.

Microsoft Dynamics AX forum

Disable SalesCreditNoteHeader button in SalesTable form through X++ code

Posted on by 55


I'm working in AX 365, I want to disable the Menu Item Button "SalesCreditNoteHeader" that is located in the (Sell > Create > Credit Note) pane of the SalesTable form, depending on certain condition.

I tried creating an event handler class with the following code:

class SalesTableFormEventHandler
    [FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesTable), FormDataSourceEventType::Activated)]
    public static void SalesTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
        FormRun     element = sender.formRun();
        FormControl creditNoteButton ="SalesCreditNoteHeader");


I debugged the class, and the if statements work correctly, but when the code enters to the else statement, the button is not being disabled.

I found that there's another class called "SalesTableInteraction" that can changes the "enabled" property of the button too.

How could I disable the button by code?

  • Gunjan Bhattachayya Profile Picture
    Gunjan Bhattachayya 35,417 on at
    RE: Disable SalesCreditNoteHeader button in SalesTable form through X++ code

    Hi Chris,

    You could do it by Creating a CoC on enableHeaderActions method in SalesTableInteraction class as there is logic for enabling disabling the button in this class. However, it depends on the condition you are using. We need to be able to replicate the same logic in this class or the related classes.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,914 Super User

Martin Dráb Profile Picture

Martin Dráb 225,549 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans