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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Custom SubGrid Button ...
Power Apps
Answered

Custom SubGrid Button with JS Action Not Firing

(0) ShareShare
ReportReport
Posted on by 12

I'll try to keep this short for my first official post 🙂 

 

I have a Model Driven App that is using an editable subgrid. Within the context of that subgrid, I have introduced a Custom Button that appears only when a record is selected. The functionality of the button is to launch a Canvas App, passing the selected record GUID and displaying a text box which defaults to showing the Comments from the record (if any) otherwise it just displays Please enter your comments here. The user would be able to enter comments and then click a button on the Canvas App to Patch those comments to the selected record, close out the Canvas App, and return to the Model Driven App with a refreshed subgrid, thus displaying the entered comments. 

 

The issue I am having is triggering of the Canvas App via the custom button. Prior to the custom button, I added the same function to an existing JS web resource associated to the subgrid, which already has an OnSelect event, and that worked successfully. As soon as I selected a record, the canvas app launched in a separate pop up window. But since attempting to switch and leverage the Custom Button, I've had no luck. I've verified that the Function Name is correct, the JS web resource is in place correctly, and I see the JS loaded in Developer Tools. I have Visibility property configured to display the custom button when 1 record is selected, and that is also working. However, clicking the button no action occurs. I have also went through the Command Checker and I see my button definition, I see the function is correct and the library is correct (with the prefixed $webresource:).

 

I will add I have 2 additional custom buttons that were created using the Power Platform Command Bar Editor and those Run Formula actions without issue. So I am leaning towards something missing or not quite right with how the JS/Function is defined within the PP Command Bar Editor because as stated above, the function triggers just fine using the OnSelect event when the code is nested within an existing separate JS. 

 

Canvas AppCanvasAppImage.png
Command Checker for Custom ButtonCommandCheckerCustomButton.png
Custom Button Definition in EditorCustomButtonDefinition.png
Subgrid Displaying Custom ButtonSubGridCustomButtonDisplayed.png
Web Resource DefinitionWebResourceDefinition.png
Function DefinitionFunctionDefinition.png

 

 

 

At this point I'm running out of ideas. Any help is appreciated!

I have the same question (0)
  • Verified answer
    Mira Ghaly Profile Picture
    11,415 Moderator on at

    @nstromb 

    I noticed one thing here in the JavaScript you are not passing any parameters to the function and your first line is trying to reference the executive context to get form context, to get the record is but what you need to do when calling your JavaScript function is to add a parameter and choose SelectedControlSelectedItemIds

     

    In your function let's say you will name the parameter itemId, then you can get record of by using itemId[0]

     

    https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/pass-data-page-parameter-ribbon-actions#grid-values

     

     

  • nstromb Profile Picture
    12 on at
    Thanks so much for the recommendation! That seemed to be what I missing! I am now able to launch the Canvas App from the custom button and it successfully passes the correct record GUID. 🙂 Now on to my next issue...getting the Patch to work!
  • MickyM27 Profile Picture
    2 on at

    Hi @nstromb ,

     

    Can you please suggest here how i can pass the record GUID to Canvas App.

    You mentioned that "the user would be able to enter comments and then click a button on the Canvas App to Patch those comments to the selected record". I want the selected record guid passed to the app.

    TIA 

  • nstromb Profile Picture
    12 on at

    Hi @MickyM27 ,

     

    Apologies that I did not see your message sooner. Not sure if you are still looking for some clarity on this one, but I may still be able to help. We ended up pivoting to a fully embedded canvas app due to some other UI needs so the process of passing the GUID to the Canvas App changed from what I was attempted to accomplish above using OOTB editable subgrid. 

     

    But in order to do what was done above with the custom button the grid, you will need to customize the command bar to establish your button, define visibility, associate your JS library with your logic, and select the Parameter SelectedControlSelectedItemIds which will then be leveraged in your code to trap the GUID. Essentially this step on the button definition is what will allow the GUID to be captured when the button is clicked and subsequently become available within your JS to be leveraged as you see fit. Not sure if you've already looked through but the MS documentation around using the customize command bar is pretty solid: Customize the Command Bar 

     

    Hopefully this is helpful. 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard