Commands are the resulting actions performed when a button is clicked. These commands are added through apps and we can decide the properties like Display of the button, visibility and actions to be performed.
Where can we add these commands?
The commands can be added at the following locations of a table:
• Main Grid
• Main form
• Subgrid view
• Associated view
Classic and Modern commands – differences
Modern commanding offers many new capabilities and is much simpler to use.
• Customizations
Classic commands are designed using manual xml editing or third party tools such as ribbon workbench and is very time consuming whereas modern commanding has its own command designer and are easy to customize. It uses power fx.
• Reliability and performance
Classic method is more error prone and its difficult to trace an error whereas modern commanding offers inline error handling and power fx gives better performance.
• Localization
In classic, localization is non-standard whereas modern commanding is standardized using export and import translations for the entire solution.
• Solution management
In classic, solution management becomes difficult as it leads to problematic solution layering. In modern commanding, the solution layering is standard and centrally managed which helps easy imports and exports.
• Visibility Rules
Classic visibility rules often had a specific rule for each scenario. With Power Fx, a declarative function replaces many classic rules. And it’s much simpler to use.
Command bar customization
We can create a new command using model driven app and can place the button in any of the areas.
1. Select model driven app you wish to add command for and click on Edit.
2. Here, we are adding a ribbon button on the Main Grid of an Account entity. Hence select Account entity and click on Edit Command Bar.
3. It will show the following screen.
4. Select Main Grid and Click on Edit.
5. Click on New and click on command.
6. It will show the properties of the Command on the right-hand side. Label the Command button and add other properties like icon, Action and visibility.
We have added a command button called Select and it can be dragged and placed anywhere in the main Grid’s other commands.
7. In Action, you can either Run formula or Run javascript by specifying the library name and function name.
8. In visibility property, we can either Show it as and when the main grid loads or based on the condition.
For example, if we want to view this button on selecting more than 1 record, we can specify the following Power Fx command.
If(CountRows(Self.Selected.AllItems) > 1, true, false)
And if we want to view this button based on record data, we can use the following Power Fx command
If(Self.Selected.Item.'Account Rating'>20, true, false)
9. There are other properties like Tooltip and Tooltip description, Accessibility text which is user’s choice. Order number gets generated based on the location of the command button.
10. Finally, Save and Publish the command bar customizations. Go back to app and test the functionality.
Note: Currently, the command designer can only be accessed through the modern app designer or within solutions for existing commands. Currently, classic commands can't be edited within the command designer.
Commands and solution management
Unlike classic commands, modern commands are treated the same as other solution components and support core solution behaviours. You can also edit existing modern commands from within a solution.
Modern commanding provides these benefits when you work with solutions:
• Add solution components that depend on your command actions.
• Block commands from being customized by using managed properties.
• View dependencies related to your modern command components.
• Troubleshoot by viewing which solutions modified the component and when using solution layers.
• Remove any unmanaged customizations if in an unhealthy state.
• Add or remove command components from a solution.
• Segment solutions and build minor updates or patches that include your modern command components.
• Modern command components work with solution upgrade so you can delete components by importing a new version.
• Standardized localization via export/import translations.
Known Limitations
• Pre-existing classic commands can’t be customized within the command designer until they’re migrated to the modern infrastructure. This includes the out-of-the-box commands, which will be migrated incrementally over time. You may continue to use other mechanisms and third-party tools for customizing classic commands.
• Dynamically populated buttons aren’t supported. We recommend creating them declaratively.
• Global application header and dashboard command bars aren’t currently supported in command designer.
Summary
Modern commanding is very easy as compared to classic commanding and anyone can customize it with minimum information. Additional training is not required like classic xml editing or third party tool usage. It is faster and performance effective than Classic one. Currently, it doesn’t support few functions and rules but it will be available in the upcoming versions.