The Power Fx command bar buttons in model driven apps have been Generally Available for a little while now and I think this is another important step forward in bringing the two worlds of canvas and model driven apps together. Here's why.
Power Fx in Command Designer
Using Power Fx in the command bar button is particularly useful when all you require is a simple action (most probably not worth writing a javascript function for) and for those of us who like to keep their solution as low code/ no code as possible. For example to open a Canvas App page from a command bar button, with Power Fx it requires no more than a single line of code:
Launch(“URL of your Canvas App”);
For the App that I am building here I am passing the Account Number as a parameter via the URL to achieve deep linking in the Canvas App. This can be achieved by using Self in the expression and drilling down to the Account Number field. IntelliSense is also available in the command designer making this nearly effortless.
Environment Variables
You may also want to use an Environment Variable to store the Canvas App’s URL especially when you are working with solutions and multiple environments. It is not very apparent how this can be achieved as typically we would create a connection to the Environment Variable tables in Canvas App studio, but this is not possible in the command designer.
Some of you might already know the solution if you have been reading the notes section in Microsoft’s documentation:
The fact that a component library is automatically created by the command designer means that you can also directly modify the component library in Canvas App Studio. This gives you the familiar user interface where you can add other data sources - and in my case, the Environment Variables tables.
You can then use the LookUp function to retrieve the Environment Variable.
If you are developing in a solution you will be glad to know that the automatically created component library is also added to your solution.
What's Next
The modern command designer has not reached its full potential as we know, but the roadmap is looking very promising especially to have to ability to edit classic commands. You can read more from the release announcement blog post.
Although not all Power Fx functions are available, this addition of Power Fx command definitely changes how developers would approach building custom command buttons. (See which Power Fx functions are currently supported here) Being able to edit the command directly in the component library shows us that Microsoft is really paying attention to maintaining the coherence of the Power Platform.
@JC
Comments