Tuesday, 15 August 2017

How to disable a form control in AX 365

// <summary>
/// Created by Rahul - 08/15/2017 for disabling LogisticsPostalAddress_Street control
/// </summary>
class LogisticsPostalAddress_EventHandler
{
    /// <summary>
    /// We are disabling LogisticsPostalAddress_Street control here
    /// </summary>
    /// <param name="args"></param>
    [PostHandlerFor(formStr(LogisticsPostalAddress), formMethodStr(LogisticsPostalAddress, updateControls))]
    public static void LogisticsPostalAddress_Post_updateControls(XppPrePostArgs args)
    {
        FormRun sender = Args.getThis();
        sender.control(sender.controlId(formControlStr(LogisticsPostalAddress, LogisticsPostalAddress_Street ))).allowEdit (false);
    }

}

Or second way

[FormControlEventHandler(formControlStr(SalesTable, ButtonLineInventory), FormControlEventType::Clicked)]
    public static void ButtonLineInventory_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        FormDataSource      salesLine_ds  = sender.formRun().dataSource("salesLine"); //DataSource form CustTable
        FormRun             element       = sender.formRun(); //form element
        FormControl         buttonLineInventReservation   = element.design(0).controlName("buttonLineInventReservation"); //New button on the form

        buttonLineInventReservation.enabled(false);
    }


Please refer below post also.
https://rahulmsdax.blogspot.com/2018/08/how-to-hide-form-control-in-ax-365.html

2 comments:

  1. Thanks Rahul for the post. Can you help on how to control any button on the same form. (Ex: Map button)

    ReplyDelete
    Replies
    1. Please look into the below post.
      http://rahulmsdax.blogspot.com/2018/08/how-to-hide-form-control-in-ax-365.html

      Delete

Foreign currency revaluation currencies not showing in drop down in dynamics 365 finance & Operations 8.0

In the previous versions you can see all currency codes in the currency drop down, but Dynamics 365 finance and operations 8.0 you don'...