Empower your employees to achieve better results.
The use of the new Modern Commands compared to the classic ones offers a great advantage, it allows the use of Power Fx formulas both to perform actions and to define visibility rules. This eliminates the need to develop scripts in JavaScript, making the configuration of these commands a low-code task.
In this article, we will explain an example of use and its application. Let’s imagine we have an application to manage our quotes and we want to add a button that indicates a quote has been lost.
Demo video
Here is a video with the step-by-step guide on how to implement the FX formula in the command bar:
Step by step
Adding the new button
a. Open the application in the Power Apps designer.
b. Select the table where you want to add the button, in this case, the “Quotes” table.
c. Click on the three dots next to the table views and select “Edit Command Bar.”
a. A window will appear asking at which level you want to create the button. Select “Main Form” to add it at the form level.
b. Here is a description of the available options:
a. In the top left corner, select “Add Command” to add a new button.
Button configuration
a. Assign a name and an icon to the button.
b. Configure the tooltip that will be displayed when the user hovers over the button.
a. In the “Action” property, select “Run Formula” to use Power Fx formulas.
b. In the formula bar, enter the action you want to perform. For example:
If(
Confirm( "Are you sure you want to mark the quote as lost?",
{ Title: "Confirm Mark Lost", ConfirmButton: "Confirm", CancelButton: "Cancel" }
),
Patch(Quotes,Self.Selected.Item,{'Status Reason': 'Status Reason (Quotes)'.Lost ,Status: 'Status (Quotes)'.Inactive});
Navigate( Self.Selected.Item )
)
Configure visibility rules
a. In the properties panel, select “Visibility” and choose “Show on condition from formula.”
b. Enter the formula for the visibility logic:
Self.Selected.Item.'Status Reason' = 'Status Reason (Quotes)'.'In Progress'
Conclusion
We have seen how to use Power Fx formulas to configure buttons in Power Apps without the need to develop scripts in JavaScript. This makes it easier to create actions and visibility rules efficiently and with less code.
Here is a visual representation of how the process will be implemented within the Model Driven App.