Using REST and JavScript, I am trying to populate the "To" field in the Email activity with values from my fields "Contact 1" and "Contact 2" The code below works, but it overwrites the Contact 1 value and in the "To"
field there is only 1 value.
Does anyone know how to populate two values into the "To" field or any lookup field using REST?
function EmailCallBack(result) {
email = result; // Set the email to result to use it later in email attachment for retrieving activity Id
var Contact1 = Xrm.Page.data.entity.attributes.get("apd_contact1").getValue()[0].id;
var activityPartyFrom = new Object();
activityPartyFrom.PartyId = {
Id: Contact1,
LogicalName: "contact"
};
// Set the "activity" of the ActivityParty
activityPartyFrom.ActivityId = {
Id: result.ActivityId,
LogicalName: "email"
};
activityPartyFrom.ParticipationTypeMask = { Value: 2 }; // 2 means ToRecipients
SDK.JScriptRESTDataOperations.Create(activityPartyFrom, "ActivityParty", ActivityPartyFromCallBack, function (error) { alert(error.message); });
var Contact2 = Xrm.Page.data.entity.attributes.get("apd_contact2").getValue()[0].id;
var activityPartyFrom = new Object();
activityPartyFrom.PartyId = {
Id: Contact2,
LogicalName: "contact"
};
// Set the "activity" of the ActivityParty
activityPartyFrom.ActivityId = {
Id: result.ActivityId,
LogicalName: "email"
};
activityPartyFrom.ParticipationTypeMask = { Value: 2 }; // 2 means ToRecipients
SDK.JScriptRESTDataOperations.Create(activityPartyFrom, "ActivityParty", ActivityPartyFromCallBack, function (error) { alert(error.message); });
}
//ActivityParty From Callback
function ActivityPartyFromCallBack(result) {
}
Mike Karls