How to Fix Button in Modern Command Bar Disappearing After Grid Item Selection

This post provides a resolution for the issue that the modern command button added to the Main Grid, Subgrid View or Associated View doesn't appear as expected after one or more grid items are selected.


In the following scenario, a Clone button is added to the Main Grid of the table before the Delete button using the modern commanding with the Visibility property to Show all the time.

But when one or more row is selected in the grid, the button disappears.


Upon troubleshooting the behaviour with Command Checker Tool, the button is not mark as (hidden) and there is no Enable Rule or Display Rule which evaluates to false. Then, what is causing the button to disappear?


Upon further research, we found that the issue is similar to this KB article in Dynamics 365 Sales. Even though the article is referring to the classic commanding, I believe the issue applies the same to the modern commanding and only item-specific buttons are shown when one or more items are selected by design.

So, how do we make our button an item-specific command in Modern Command Bar? What are the options in the modern commanding which are equivalent to the <SelectionCountRule> or "Mscrm.AnySelection" Enable Rule as mentioned in the KB article?


The option equivalent to <EnableRule Id="Mscrm.AnySelection" /> to make the modern command button as both an item-specific command and a non-item specific command (and display in both cases) is by switching the Visiblility property as "Show on condition from formula" and set the Power Fx visible property as just true. (as mentioned in the forum threads like this and this)


But in my case, the Clone button needs to be visible when one and only grid item is selected. In that case, the Power Fx visible property equivalent to the SelectionCountRule as mentioned in this Classic versus modern visibility rule comparison is as below.
 If(CountRows(Self.Selected.AllItems) = 1,true , false)  



In summary, the buttons added to the grid views with Visibility property = Show are treated as non-item specific command and the Visiblility property needs to be changed as "Show on condition from formula" to make it available when one or more grid items are selected.

Comments

Popular Posts