Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Microsoft Dataverse
Unanswered

Hide PowerFx Command based on parent form

(0) ShareShare
ReportReport
Posted on by 76

I have a table called DriverInductions, which is a custom many to many. That is, it has two lookup columns, one for Driver and one for Induction, creating a custom many to many, with additional columns (which Dataverse doesn't allow in its many to many relationships).

 

It has an "Active DriverInductions" view, which has a PowerFx "+ Add Existing Induction" command button. If the view is placed in the Induction Main Form, that button works as expected but the view can also be placed in the Driver Main Form, where the button doesn't make sense, instead it needs to show a "+ Add Existing Driver" button and hide the Add Induction button.

Is there a way to write a formula that sets the command visibility based on the parent?

 

This question mentions making a reference to the parent record but I am not sure if I can use this for what I need.

With(
{
PARENT_RECORD: First(Self.Selected.AllItems).<YOUR_LOOKUP_COLUMN_TO_PARENT_RECORD>
},

CountRows(Filter('Questions','Questionnaire'.'Questionnaire'=PARENT_RECORD.<YOUR_PARENT_RECORD_IDENTIFIER> And 'Status Reason'='Status Reason (Questions)'.Unanswered))=0
)

 

Bonus question. How does one debug a PowerFx command? I see that you can put a breakpoint in Javascript on the line for the formula but debugging a minified JS script is rather difficult to say the least.

Categories:
  • ivan_apps Profile Picture
    2,187 Super User 2025 Season 1 on at
    Re: Hide PowerFx Command based on parent form

    Correct - the commands are not view centric so you can't target a command bar button to only appear in certain views with OOB view criteria.  I have not tried querying the current view - it would have to be in javascript but I imagine it would be some DOM traversing on the View selector or the grid fetchXML. It would be prone to breaking if MS chooses to change the DOM layout.

  • srx_nstratton Profile Picture
    76 on at
    Re: Hide PowerFx Command based on parent form

    I was trying to avoid RibbonWorkbench which is so slow to publish, while the commands publish relatively quickly.

     

    It seems like the commands are table centric and not view centric? Is there any way to query the name of the view the button is on? If so, I could create two views, with different names and hide a button based on the view, rather than the parent.

     

    That's a handy tip to use notify. Thx

  • ivan_apps Profile Picture
    2,187 Super User 2025 Season 1 on at
    Re: Hide PowerFx Command based on parent form

    Good question… the post you’re referring to has a Main form button whereas you have a subgrid button, so the context is very different. With PowerFX… I don’t think this is possible.

    I believe this is possible with a JavaScript button, you should be able to reference the ‘Parent.Xrm’ context and get the entity type to complete your show/hide. I would def recommend using the RibbonWorkbench tool if you go this route. 

    Edit: Debugging PowerFX commands - the best way I’ve come up with is to break things down in discrete (with) actions, and use Notify() to inform you of the state of variables along the way. For example -

    With({
    var1 : [small staged query/data element],

    var2 : [same as above]

    },

    Notify(“var1: ” & var1);

    Notify(“var2:” & var2);

    [your action here]

    )

     

    you would also wrap your action around some error handling so it can notify you if your Patch command or other command failed and display the error message.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Microsoft Dataverse

#1
mmbr1606 Profile Picture

mmbr1606 22 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 19

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 15 Super User 2025 Season 1

Overall leaderboard

Featured topics