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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,280 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,046 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans