Pragmatic Works Nerd News

Customize Actions on SubGrids in Power Apps Model-Driven Apps

Written by Brian Knight | Oct 24, 2023

Brian Knight of Pragmatic Works provides a tutorial on how to create a custom button in Power Apps Model-Driven Apps to approve multiple items in a subgrid at once. This eliminates the need to approve or reject items on a product-by-product basis.

 

Key Steps:

1. Edit the Application: Navigate to the solution area and open the app you want to edit.


2. Edit the Command Bar: In the application, go to the 'Products' table and click on 'Edit Command Bar'.


3. Add Button: Add a custom button, name it, and select an icon.


4. Implement Power FX Code:

    • Choose the Power FX option for action.
    • Write the Power FX code that specifies what will happen when the button is clicked.
    • Use the "ForAll" command inside a "Patch" command for looping and updating the selected records.
    • Include a "Notify" command to alert the user about the successful operation.

5. Deploy and Test: After adding the code, save and deploy the application to see the new custom button in action.


Additional Information:

  • Limitations: At the time of the recording, existing buttons could not be disabled using this feature. Third-party tools like Ribbon Workbench are needed for that.

  • Visibility Control: By default, the button will not appear when items are selected in the subgrid. To control its visibility, add a "Show on Formula on Condition" with appropriate conditions.

Tips:

  • Validate your code often to ensure that you have no errors before adding functionalities.
  • The Command Library provides an extended area for easier code implementation and better error handling.

Brian concludes by noting that this approach is much faster than the traditional methods of approving or rejecting items individually. It offers a low-code way to enhance user experience and operational efficiency.