Hello all,
I'm trying to update an activity party by Odata call, however, i'm facing issues to achieve that.
Basically, i've a requirement that sometimes we receive one email, and we want to change the sender. For that we've created one html form where the user can search by contacts and then set it into email.
I've created a piece of javascript code, however when i apply it, it changes the sender but at the same time erases all the recipients also CC and BCC content.
On below there is the piece of code that i've used to test.
Did someone already done something like this or have a workaround or another way to achieve it? I'm on version 8.2.
//first try, to set the lookup value //didn't worked because the from that we are trying to set is systemuser. function SetEmailFrom() { var contactID = "<contactId>"; var object = new Array(); object[0] = new Object(); object[0].id = contactID; object[0].name = <name>; object[0].entityType = "<entity type>"; window.top.opener.frames[0].Xrm.Page.getAttribute("from").setValue(object); }
Now with odata trying to set the the "From"
/with this code, i'm able to set the "From" but the recipient,CC and BCC are erased. function SetEmailContact(contGui) { var emailGuid = window.top.opener.frames[0].Xrm.Page.data.entity.getId(); var emailGuidClean = emailGuid.replace('{', '').replace('}', ''); var entity = {}; var parties = []; //ActivityParty (From) var sender = {}; sender["partyid_contact@odata.bind"] = "/contacts(" + contGui + ")"; sender["participationtypemask"] = 1; //From //add this to collection parties.push(sender); entity["email_activity_parties"] = parties; var queryToAssignEmail = "/api/data/v8.2/emails(" + emailGuidClean + ")"; alert(queryToAssignEmail); var req = new XMLHttpRequest(); req.open("PATCH", Xrm.Page.context.getClientUrl() + queryToAssignEmail, true); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.setRequestHeader("If-Match", "*"); req.onreadystatechange = function () { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 204) { //Success - No Return Data - Do Something } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send(JSON.stringify(entity)); }
If i try to update or create an activity party on the ActivityParty entity, it says that is not possible to create and update this entity.
Could you please give a hint about this?
Thank you in advance
Best Regards,
DR
*This post is locked for comments
I have the same question (0)Hi Guys,
Any idea about this?
Basically what is struggling us is the fact that we are not able to change the "from" of email via Javascript.