Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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"

share|improve this question
Can you please clean up the tags? SugarCRM, dynamics-crm-4, and dynamics-crm-2011 are all different and would have different solutions. – Andy Meyers Apr 25 at 3:18
Please mark my answer if you are happy with it. – Bvrce Apr 25 at 13:41

1 Answer

up vote 1 down vote accepted

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:

  • 2 parameters are passed for each lookup field
  • The GUID as the name of the lookup field (account if account if the name of the lookup field in the new email)
  • The name of the lookup in the source entity as a special parameter (accountname)
  • Note: there is no field called "accountname", but there is a field called "account" in this hypothetical entity
share|improve this answer
thanks. Also can u help me for getting "Send direct email". Actually in Subgrid View of my customized entity i didnt have "Send Direct Email button" , but while opening with Ribbon editor i can see there "Send direct email button" but its not visible in form. Now how to show that button in subgrid View form? – Vishnu Apr 25 at 3:54
Add a display rule to the button. This display rule displays the button when the record is active: <EnableRule Id="Mscrm.SubGrid.incident.EnableRule.Enable"> <ValueRule Field="statuscode" Value="1" Default="false" /> </EnableRule> If you cannot add display rules with the ribbon editor then maybe you should ask another question about display rules. The ribbon editor will also have to allow the editing of existing buttons; otherwise you could consider adding a new button and copying the "Command" attribute of the Send Direct Email button. – Bvrce Apr 25 at 4:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.