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

Community site session details

Session Id : GNVtTTwGd/iMzl2+871zFz
Power Apps - Power Apps Pro Dev & ISV
Answered

Showing buttom depending on the entity's view

Like (0) ShareShare
ReportReport
Posted on 2 Mar 2023 16:04:44 by 35
Hello there!


I'm creating a Model Driven App and I want to show a custom button created on the main grid when I'm in a specific entity's view. For example: If I'm on "View A" the button shows and if I'm on "View B" the button is hidden.

Is this possible?

 

Any help is appreciated

  • Verified answer
    Federico Pelliccia Profile Picture
    142 on 03 Mar 2023 at 11:33:15
    Re: Showing buttom depending on the entity's view

    You could try to use a custom javascript enable rule. You can pass the executionContext (in main grid it should be SelectedControl) to method and call the function

    To pass in the execution context (form context or grid context) information to JavaScript function for your ribbon actions, specify PrimaryControl for the form context, or SelectedControl for the grid context as the <CrmParameter> value in your ribbon definition. SelectedControl will pass in the grid context, for both subgrids and homepage grids. The passed in PrimaryControl or the SelectedControl value is used as an argument in your JavaScript function for form context or grid context respectively.

    Then try this code:


     

     doSomething(SelectedControl ) { 
    var gridContext = SelectedControl
    var viewSelector = gridContext.getViewSelector();
    var gridId = viewSelector.getCurrentView()[0].id // I don't know if it is an array or not
    //If not: var gridId = viewSelector.getCurrentView().id 
    
    // Now write your logic:
    if gridId == 'YOUR_VIEW_ID'{
     return true;
     }
    else{
    return false;
    }

     


    For more information: Pass data from a page as a parameter to Ribbon actions (model-driven apps) - Power Apps | Microsoft Learn


  • AbdulWahab Profile Picture
    517 on 03 Mar 2023 at 03:53:35
    Re: Showing buttom depending on the entity's view

    Hi @AntonioMF ,

     

    Below are the links that might be going to help you:

    If I answer your question then please mark it as verified.

     

    Let me know if I can provide you with more details.

     

    Thanks
    Regards,

     

    Abdul Wahab
    Power Platform & Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: https://www.linkedin.com/in/abdul-wahab-a5b8b011a/
    Youtube Channel: https://www.youtube.com/channel/UCBjgLqLK_2kU-3bwo4McrTw

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473