Thursday, 2 August 2018

Hide a form control in AX 7

In this example I'm going to hide "Description' field from the ledgertrans form.

For that I have created a event handler class in the extension model(Newly created model for extensions and event handlers ).


class LedgerTransAccount_Eventhandler
{
    [FormDataSourceEventHandler(formDataSourceStr(LedgerTransAccount, GeneralJournalAccountEntry), FormDataSourceEventType::Activated)]
    public static void LedgerTrans_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
    {
        GeneralJournalAccountEntry           generalJournalAccountEntry     = sender.cursor(); //selected record
        FormDataSource      generalJournalAccountEntry_ds  = sender.formRun().dataSource("GeneralJournalAccountEntry");
        FormRun             element       = sender.formRun(); //form element
        FormControl         tabOverview   = element.design(0).controlName("TabOverview"); //New button on the form
        element.control(element.controlId(formControlStr(LedgerTransAccount, LedgerTrans_Txt ))).visible(false);

    }

}

No comments:

Post a Comment

Adding a newline into a string in C# and X++

Below is the sample code we can use for  adding a newline after every occurrence of "@" symbol in the string in C#   using System...