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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Model-Driven App Loadi...
Power Apps
Unanswered

Model-Driven App Loading Grid Detail to Custom Page

(0) ShareShare
ReportReport
Posted on by 34

Hello all,

 

I've been searching for a way to accomplish this and have not found a good solution. It seems that someone out there might have tried to do something similar in the past...

Situation:

  • I have a model-driven view (grid) that contains the Primary Contact's Email.
  • I have a custom page that has a field to hold all of the emails of the records selected in the grid.
  • I am successfully loading the grid to a panel on the right and passing the selected items from the grid to page, but the only item passed is the recordId of the account.
  • Microsoft documentation states that if we are trying to get the GridContext of the model-driven app to be available to the custom page we are to add the parameter "SelectedControl" to the Command button that displays the custom page.
  • I'm also passing the parameter "SelectedControlsSelectedItemReferences", which returns the Id, Name, TypeName, and TypeCode for each selected row in the grid.

Issue:

I cannot figure out how to access the grid column that contains the Primary Contact's email address for the selected rows.

 

It seems as though I should be able to do something like this:

 

function OpenSendEmail(selectedControl,selectedItems,selectedItemCount) {
	var gridContext = selectedControl;
	var selectedEmail = gridContext.getAttribute('emailaddress1');
	

// display side pane
	if (selectedItems) {
		var paneInput = {
			title: "Send Email",
			paneId: "SendEmail",
			canClose: false,
			width: 600
		};
		var navigationOptions = {
			pageType: "custom",
			name: "vc_sendemail_aed9d",
			entityName: selectedControl._entityName
		};
	};
	
	Xrm.App.sidePanes.createPane(paneInput).then((pane) => {
		pane.navigate(navigationOptions)
	});

	console.log(selectedControl);
	console.log(selectedItems);
	console.log(selectedEmail);
	console.log(selectedItemCount);
	console.log(navigationOptions);

}

 

But the third line, throws an error stating that gridContext.getAttribute is not a function. With that, how do I grab the value contained in the 'emailaddress1' column of each selected row?

Categories:
I have the same question (0)
  • Verified answer
    cha_cha Profile Picture
    4,932 Moderator on at

    Hello @ronkochanowski 

     

    Based on this documentation, I think you need to use more methods within GridContext Object. I've done a couple of ReactJS projects in the past month so have gone thru this but not in Model Driven Apps. Your code should flow like this:

     

     //Choose 1 get rows - use the getControl method and pass the grid name.
     var allRows = gridContext.getGrid().getRows(); //all rows
     var allRows = gridContext.getGrid().getSelectedRows(); //selected rows only
    
    
     //loop through rows and get the attribute collection
     allRows.forEach(function (row, rowIndex) {
    
     //get the attribute Collection
     var attributeColl = row.getData().getEntity().attributes;
     
     //get the value
     var emailVar = attributeColl.getByName("emailAddress1").getValue();
    
    
     

     

    My references are from the Dynamics community.

    https://community.dynamics.com/365/f/dynamics-365-general-forum/363243/get-the-value-of-the-selected-data-in-a-subgrid

    https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/371356/need-help-finishing-javascript-event-that-counts-the-total-yes-s-in-a-grid-and-gives-a-warning-message-if-the-yes-count-4

     


      ✔️
    Just in case you my answer helped you solve your problem, please mark/accept this as a SOLUTION This helps community members if they experience a similar issue in the future.

     

      🔗
    🕸bistek.space  🐦 @cha_bistek  📺 @BisTekSpace 

     

     

     

     

  • ronkochanowski Profile Picture
    34 on at

    @cha_cha ,

    Wow!  Thank you!  This was actually pretty straight forward.  I can now see the collection with the columns from the Account entity.  Next, drilling into the Contact entity to grab the Primary Contact's email, which isn't revealed in the collection.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard