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:
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?
Solved! Go to Solution.
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.
✔️ | 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 |
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 |
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.
✔️ | 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 |
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 |
@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.