There is one customized entity named as "Add to Campaign" . Since there is no default "Email" button in sub-grid , so i placed one customized button and provided javascript to open Email form , and the Email form opens good. But now the problem is , cant able to get selected records "Email field" in "Send to field" in Email Form. so how to get selected record email to be displaced in "Email Form"
Open the email form with parameters:
Xrm.Utility.openEntityForm("email", null, param);
var param = {}; // passed as parameters to the new email form
if(Xrm.Page.getAttribute("-- LogicalNameOfField --") // make sure that the field has a value
param["-- LogicalNameOfFieldInNewEmail --"] = Xrm.Page.getAttribute("-- LogicalNameOfField --"); // passes a field value to the new form
// This passes a lookup field as a parameter to the new form
if(Xrm.Page.getAttribute("-- LogicalNameOfLookup --").getValue() != null) { // make sure that the lookup field is not empty or we will have a problem trying to access [0].id and [0].name
param["-- LogicalNameofLooupFieldInEmail --"] = Xrm.Page.getAttribute("-- LogicalNameOfLookup --").getValue()[0].id;
param["-- LogicalNameOfLookup --" + "name" (eg. "accountname")] = Xrm.Page.getAttribute("-- LogicalNameOfLookup --"].getValue()[0].name;
Xrm.Utility.OpenEntityForm("LogicalEntityName", null, param); // open the form and pass parameters
Take note of how the lookup field is passed as a parameters: