Hi,
I want to send mail from custom entity by clicking on button. I created custom entity, button. When I click on the button it will call email activity. I did set up default subject as name of the account. But I could not set regarding field by default. I got error: Object expected when loading the form. Please help me to solve this issue.
I have got few solution but it did not work. Please find below the java code I have used for this.
1. I created 3 parameters. parameter_regardingid,parameter_regardingname,parameter_regardingtype on the form parameters as shown below screen-shot. Publish the form.
2. I added below java code in form onload of custom entity and publish
function Form_onload()
{
var param=Xrm.Page.context.getQueryStringParameters();
var regardingId=param["parameter_regardingid"];
var regardingName=param["parameter_regardingname"];
var regardingType=param["parameter_regardingtype"];
if (regardingId != undefined)
{
Xrm.Page.getAttribute(“regardingobjectid”).setValue([{id:regardingId, name:regardingName, entityType:regardingType}]);
}
}
3. I added below java codes on button event.
function sendmail()
{
var parameters = {};
var Regarding = Xrm.Page.getAttribute(“regardingobjectid”).getValue();
parameters["parameter_regardingid"] = Regarding[0].id;
parameters["parameter_regardingname"] = Regarding[0].name;
parameters["parameter_regardingtype"] = Regarding[0].entityType;
Xrm.Utility.openEntityForm("email",null,parameters);
}
pnoushu@hotmail.com