You need to enable or disable a button on a standard form based on certain conditions, such as: 

Introduction:

In X++, enabling or disabling buttons in a standard form (also known as a form or a dialog in Dynamics AX/365) is typically done by manipulating the button’s properties within the form’s code. This can be done by using the control methods available in the form’s data or UI elements. 

High level resolution steps 

    Detailed resolution steps 

      Step 1: Create a generic method to retrieve the user in the workflow type event handler class. 

      Code snippet: 

      
      [ExtensionOf (FormDataSourcestr(CustTable,CustTable))] 
      
      final class DAXCustTableform_Extension 
      
      { 
      
          public int active() 
      
          { 
      
              FormDataSource fds       = this; 
      
              CustTable      custTable = fds.cursor(); 
      
              int ret                  = next active(); 
      
              FormControl frm          = fds.formRun().design().controlName(formControlStr(CustTable, mibCustOpenBalanceCurrency)); 
      
        
      
              if(custTable.Currency == 'EUR') 
      
              { 
      
                  frm.enabled(true); 
      
              } 
      
              else 
      
              { 
      
                  frm.enabled(false); 
      
              } 
      
              return ret; 
      
          } 
      
      } 
      
       
          

      Code Explanation: 

      Purpose: 

      This extension ensures that the mibCustOpenBalanceCurrency control is only editable if the customer’s currency is Euro (EUR). Otherwise, it is disabled. 

      Output 

        When the Currency is EUR you can see the balance button enabled. 

        Leave a Reply

        Your email address will not be published. Required fields are marked *