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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Create a Email Activity from Incident Page. (javascript)

(0) ShareShare
ReportReport
Posted on by 25

Hi Guys, 

I'm trying to create an Email Activity from the Incident page of our CRM (CRM2015)

it works, but i cant figure out how to populate the "to" and "from" 

I'm sure I'm missing a small detail, just not sure what it is :(

var emailSubject=parent.Xrm.Page.getAttribute('title').getValue();
var CaseOwner=parent.Xrm.Page.getAttribute('ownerid').getValue()[0]

var FromParty = new Array()
FromParty[0] = new Object();
FromParty[0].id =id= CaseOwner.id;
FromParty[0].entityType = "systemuser";
FromParty[0].type = "8";
FromParty[0].name = CaseOwner.name;

var entity = {};
entity.RegardingObjectId = {
Id: parent.Xrm.Page.data.entity.getId(),
LogicalName: "incident"
};
entity.Subject = "re:" + emailSubject
entity.From = FromParty

var req = new XMLHttpRequest();
req.open("POST", encodeURI(Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/EmailSet"), false);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function () {
if (this.readyState === 4) {
this.onreadystatechange = null;
if (this.status === 201) {
var result = JSON.parse(this.responseText).d;
} else {
alert(this.statusText);
}
}
};
req.send(JSON.stringify(entity));
result=JSON.parse(req.responseText).d;
var EmailId=result.ActivityId;

var options = {openInNewWindow : true};
parent.Xrm.Utility.openEntityForm("email",EmailId,null,options) // for now, cant figure out how to use windows.open for a email form.

I have the same question (0)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 74 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 31 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans