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 / Command Button on Main...
Power Apps
Answered

Command Button on Main Grid doesn't return Parameter(s)

(0) ShareShare
ReportReport
Posted on by 73

Hi,

 

I've created a Command Button on a Main Grid for Contacts, in a Model Driven app, that's calling a JavaScript, that's opening a custom page popup <-- all this works.

 

I then configured the Command Button to pass one parameter ("SelectedControlSelectedItemIds").

The JavaScript function is called with above parameter.

On the custom page for App.OnStart, I then declare a variable as Param("recordIds").

 

JavaScript on the Command Button, that opens the custom page.

 

 

function openCommentPopupGrid(SelectedControlSelectedItemIds)
{
 // Centered Dialog
 var pageInput = {
 pageType: "custom",
 name: "rkn_addcommentandclose_92b84",
 recordIds: SelectedControlSelectedItemIds.join('|');
 };
 var navigationOptions = {
 target: 2,
 position: 1,
	height: {
	 value: 350,
	 unit: "px"
	},
	width: {
	 value: 20,
	 unit: "%"
	},
	title: "Add Comment"
 };
 Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
 function () {
 // Refresh the main form when the dialog is closed
 }
 ).catch (
 function (error) {
 // Handle error
 }
 );
};

 

 

Output from the JavaScript, when debuggin:

2023-09-06 11_00_57-Contacts Active Contacts - Power Apps.png

 

Command Button

2023-09-06 10_39_47-.png

 

Code in Custom Page running on App.OnStart

 

Set(varRecordIds, Param("recordIds"));

 

 

Result on the Custom Page (see label RecordIds), which is a label configured like this: "RecordIds: " & varRecordIds

2023-09-06 11_09_01-Contacts Active Contacts - Power Apps.png

 

And from there the parameter is not passed into the custom page.

I've tried to use different parameters, just to see if there was a difference, but still nothing gets passed into the custom page.

I also tried to add a static variable to the JavaScript, which also was not passed into the custom page.

I also tried to add a static string parameter to the Command Button, which also was not passed into the custom page.

 

The outcome is the same, whether I chose 1, 2, or more records on the Main Grid.

 

When doing an almost identical setup, as above, but with a Command Button on a Main Page, it works. - i.e. in runs on a single record on a form.

Categories:
  • Verified answer
    m.jeppesen Profile Picture
    73 on at

    Found a solution.

     

    I changed the parameter name in the JavaScript to be "recordId" instead of "recordIds" - then of cause also changed the Param() function running app.onStart() to reflect the change.

     

     

    So now JavaScript looks like this:

     

     

    function openCommentPopupGrid(SelectedControlSelectedItemIds)
    {
     // Centered Dialog
     var pageInput = {
     pageType: "custom",
     name: "rkn_addcommentandclose_92b84",
     recordId: SelectedControlSelectedItemIds.join("|")
     };
     var navigationOptions = {
     target: 2,
     position: 1,
    	height: {
    	 value: 350,
    	 unit: "px"
    	},
    	width: {
    	 value: 20,
    	 unit: "%"
    	},
    	title: "Add Comment"
     };
     Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
     function () {
     // Refresh the main form when the dialog is closed
     }
     ).catch (
     function (error) {
     // Handle error
     }
     );
    };

     

     

     

    app.onStart()

     

    Set(varRecordIds, Param("recordId"));

     

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!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard