Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 175888

Disable SalesCreditNoteHeader button in SalesTable form through X++ code

$
0
0

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?


Viewing all articles
Browse latest Browse all 175888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>