Customizing Model-Driven App Command Bar with Power FX Using the Command Designer 💡
In this video, Brian Knight from Pragmatic Works demonstrates how to enhance model-driven applications by customizing the command bar using Power Fx. This approach bridges the gap between canvas and model-driven apps, allowing developers to introduce custom buttons and automate processes directly within their applications.
Understanding the Evolution of Model-Driven Apps
Brian explains that the distinction between canvas apps and model-driven apps has been gradually diminishing. With features like custom pages and now Power Fx-enabled command bar customization, developers can leverage canvas-like capabilities within model-driven environments.
Scenario Overview: Loan Payment Schedule Automation
To demonstrate the functionality, Brian builds a simple loan management app. The goal is to generate a payment schedule based on loan details such as:
- Loan amount
- Start date
- Payment duration (e.g., 12 months)
By clicking a custom button, users can automatically generate a full payment schedule.
Step 1: Editing the Command Bar
Brian begins by navigating to the solution and selecting the appropriate table. He then chooses to edit the command bar for the main form. This allows developers to:
- Add new buttons
- Customize existing commands
- Select between JavaScript or Power Fx logic
He emphasizes selecting Power Fx to enable low-code customization.
Step 2: Creating a Custom Button
A new button labeled "Create Payment Schedule" is added. Developers can:
- Assign custom icons
- Control visibility using formulas
- Define actions using Power Fx
This button becomes the trigger for generating loan payment records.
Step 3: Connecting Data Sources
Brian highlights the importance of connecting relevant tables inside the command library. In this case:
- Main Loan table
- Loan Payments table
This ensures the button can interact with multiple data sources.
Step 4: Writing Power Fx Logic
The core functionality is implemented using Power Fx. Brian outlines the logic in structured steps:
- Remove Existing Records
- Uses the
RemoveIffunction - Deletes existing payment schedules for the selected loan
- Uses the
- Loop Through Payment Terms
- Uses
ForAllwithSequence - Iterates based on the number of payment terms
- Uses
- Create New Records
- Uses the
Patchfunction - Inserts new payment records into the Loan Payments table
- Uses the
- Calculate Payment Dates
- Uses
DateAdd - Automatically increments the payment date per iteration
- Uses
- Provide User Feedback
- Uses
Notifyto confirm schedule creation
- Uses
Step 5: Publishing and Testing
After implementing the logic, Brian stresses the importance of:
- Saving and publishing changes
- Using "Publish All Customizations" if updates do not reflect
- Refreshing the browser to load the latest version
Common Challenges and Tips
Brian shares several practical insights:
- Some Power Fx functions may not yet be supported in command bars
- Publishing issues may require manual intervention
- Testing with small changes (like adding symbols) helps confirm updates
Final Output
Once completed, clicking the custom button generates a full payment schedule:
- Sequence numbers (1 to 12)
- Consistent payment amounts
- Monthly payment dates starting after the loan start date
Conclusion
Brian concludes that Power Fx integration into command bars significantly enhances the flexibility of model-driven apps. Developers can now build powerful, low-code solutions that automate business processes and improve user experience.
This feature opens the door to more advanced customizations, making it easier to extend functionality without relying heavily on traditional coding methods.
Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on Power Fx and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up-to-date on the latest tips and tricks.
Sign-up now and get instant access
ABOUT THE AUTHOR
SQL Server MVP and founder of Pragmatic Works. Brian has been working with SQL Server as a DBA and business intelligence professional since 1998. He has written more than 15 books on the topic and has spoken at dozens of conferences.
Free Community Plan
On-demand learning
Most Recent
- Migrate Dataverse Data Between Environments Using the Data Migration Utility
- Customizing Model-Driven App Command Bar with Power FX Using the Command Designer 💡
- Microsoft Teams: Introduction [Beginner to Pro Teams Series - Ep. 1]
- Power Automate Tutorial: Get Changes for Updated Item in SharePoint
private training

Leave a comment