Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Disable SalesCreditNoteHeader button in SalesTable form through X++ code

(0) ShareShare
ReportReport
Posted on by 55

Hi!

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 = element.design().controlName("SalesCreditNoteHeader");


        if(condition)
        {
            creditNoteButton.enabled(true);
        }
        else
        {
            creditNoteButton.enabled(false);
        }
    }
}

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
    35,421 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.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,430 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,043 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans