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

3 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
  2. I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. Disability niche

    ReplyDelete

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...