Good information tends to be complex and made up of raw data that can be overwhelming, to say the least. One of the values of a good ERP software is to bring together raw data into an organized format. This empowers the end user to make informed decisions. The interconnectivity of data leads to developers adding context sensitive actions designed to aid the human behind the keyboard to easily move between relational data in a somewhat natural way.
Intuitive navigation relies on context sensitive factors to drive when actions are enabled or even visible. When the action on the grid depends on data in the current row of the grid, Acumatica allows for dynamically controlling the state of the action, specifically Enabled or Disabled. However, there are a few pieces required to control the stated of the action based on data within the currently selected row.
First, define the simple action to redirect to the Sales Order Entry screen for the sales order identified in the grid row. This will be placed on the grid menu area rather than the main navigation menu, so DisplayOnMainToolbar = false in line 4 will prevent this action from being placed on the main menu.
Next, within the DAC, add a Boolean unbound field to reflect whether the row identifies a Sales Order. This field will be marked invisible and disabled, but it MUST be added to the ASPX page in the next step. Notice the PXFormula which sets the field to True when the SOOrderNbr field is not null, and otherwise sets it to False. Alternatively, if more complex code is required, use a FieldSelecting or RowSelecting event to populate the value in the graph. When using PXFormula in the DAC, the field is always populated. When using event handlers, the field is only populated when using the graph. If more complex code is required to set the field, it may be best to add the field to the database and update the DAC to define the field as PXDBBool so the value is saved and available in places such as Generic Inquiries.
Once the field is added to the DAC, it is time to add the action to the grid toolbar. Also, add the hidden HasSO field. Remember, this field is already defined as hidden, but the ASPX page needs access to the value to use it on the presentation layer as it builds the page for the end user. Forgetting this step can be a frustrating cause of endless troubleshooting.
Be sure to compile the code and update the files in your customization project to pick up the change in the DLL. Then publish and enjoy your new context sensitive action in the grid. When the grid row is linked to an SO, the action now should be enabled. Otherwise, it should be disabled.