Tayana Solutions

Dynamically Changing Control Types in Sales Order Entry Screens

This video demonstrates how to change the control type of a field in a sales order entry screen based on the order type. 

(a) Challenges

The customer requires a sales order entry screen where the order type field can dynamically switch between a text box and a drop-down list depending on the selected order type. Additionally, certain fields, such as the order number, need to be enabled or disabled based on the order status. 

(b) Solution and Benefits

This video outlines a solution using the pxFieldAttribute in Acumatica’s framework. 

Steps: 

  • Utilize the pxFieldAttribute to define a control that can switch between a text box and a combo box (drop-down list). 
  • In the UI field definition, add a pxStringList attribute to enable dynamic control type changes. 
  • Use the UI field attribute control property to manage the field’s visibility. 
  • Implement logic in the row selected event to dynamically change the control type based on the order type. For example, set pxControlType to ComboBox for a drop-down list and TextBox for a text box. 
  • Enable and disable fields based on the order status using logic in the row selected event. 
  • For customized control modification, create a class (e.g., CustomControlTypeAttribute) that inherits from pxEventSubscriberAttribute and IPxFieldSelectingSubscriber. 
  • Within the OnFieldSelecting event of this custom class, define the logic for changing the control type to a combo box, set the length, enable/disable status, and populate the string list with values and corresponding labels. 
  • Apply the custom attribute (CustomControlType) in the data access class to ensure the screen behavior adapts based on the order type and status. 

Benefits

  • Enhanced User Experience: Provides a more intuitive and efficient user experience by dynamically adjusting the interface based on context. 
  • Flexibility: Allows for greater flexibility in designing sales order entry screens, accommodating various order types and statuses. 
  • Improved Data Accuracy: By dynamically controlling field types and enabling/disabling fields, the solution can help prevent data entry errors. 

 

 

This approach empowers developers to create more dynamic and user-friendly interfaces in Acumatica, ultimately leading to greater user satisfaction and improved data quality.