web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

subgrid command be shown or hidden based on a parent form field?

(0) ShareShare
ReportReport
Posted on by

I have a form with a related-record subgrid. I want to add custom buttons to the subgrid command bar and show or hide those buttons based on a field value from the parent form record.

I tried using a Power Fx visibility formula similar to:

powerfx
 
Self.Selected.Item.'Choice Column' = 'Choice Column'.Value

However, Self.Selected.Item appears to reference a selected row in the subgrid rather than the parent form record. Since these are “New” buttons, there may not be a selected subgrid row.

My questions are:

  1. Can a modern command designer subgrid button be shown or hidden based on a field on the parent form?
  2. Is there a supported Power Fx formula for accessing the parent form record from a subgrid command?
  3. Can PrimaryControl be used for visibility, or is it only available for the button action?
  4. If this is not supported with modern commanding, what is the recommended approach?
  5. Would the solution require JavaScript, classic ribbon rules, RibbonDiffXml, Ribbon Workbench, separate forms, or separate subgrids?
  6. Is there official Microsoft documentation or an example for this scenario?

I am trying to determine whether this is possible using the modern command designer before using a more complex ribbon customization approach.
 

Categories:
  • Suggested answer
    11manish Profile Picture
    1,545 Super User 2026 Season 2 on at

    Power Fx modern commanding doesn't provide a general PrimaryControl-style parent-form reference for a subgrid command. Self.Selected.Item refers to the subgrid selection and is blank for an unselected/New command. For a button whose visibility depends on a parent-form field, use a JavaScript visibility rule with the form context. Keep RibbonDiffXml/Ribbon Workbench as a legacy/advanced alternative rather than the first choice.

    If this is a new implementation, stay with the modern command designer for the command itself, but use a JavaScript visibility rule to read the parent form field. There is no need to redesign the form, create duplicate subgrids, or immediately move to Ribbon Workbench just to implement this requirement.

     

    This is the cleanest approach because it separates the two contexts correctly: the subgrid hosts the command, while the parent form provides the business condition.

  • Suggested answer
    Manoj - ManoVerse Profile Picture
    1,462 Super User 2026 Season 2 on at

    Based on current Microsoft documentation, this isn't supported directly with modern commanding.

    For a subgrid command, the Power Fx visibility context is the subgrid itself. Self.Selected.Item and Self.Selected.Items work with records from the grid context and selected rows. 

    Self.Selected as the control context for command visibility, but there is no supported Power Fx expression that provides direct access to the parent form record from a subgrid command visibility rule.

    PrimaryControl can be used in command actions (for example, JavaScript actions), but it is not documented as a value that can be used in a modern command visibility formula.

    If you need to show or hide a subgrid button based on a field on the parent record, the recommended approach is still a classic ribbon customization (Ribbon Workbench/RibbonDiffXml) with a JavaScript Display Rule or Enable Rule, where you can access the parent form context. Alternatively, keep the button visible and perform the validation in the button action itself.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 38 Super User 2026 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 32 Super User 2026 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 30 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans