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
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
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
WarrenBelz
637
Most Valuable Professional
stampcoin
570
Super User 2025 Season 2
Power Apps 1919
473