function CreateEmail() { var quoteId = Xrm.Page.data.entity.getId(); quoteId = quoteId.replace(/[{}]/g, ""); var OwnerLookup = Xrm.Page.getAttribute("ownerid").getValue(); OwnerGuid = OwnerLookup[0].id; OwnerGuid = OwnerGuid.replace(/[{}]/g, ""); var CustomerLookUp = Xrm.Page.getAttribute("customerid").getValue(); var AccountId = CustomerLookUp[0].id; AccountId = AccountId.replace(/[{}]/g, ""); var webapiPath = Xrm.Page.context.getClientUrl() + "/api/data/v8.0/emails"; var email = {}; //Lookup email["regardingobjectid_quote@odata.bind"] = "/quotes(" + quoteId + ")"; //Regarding is quote email["subject"] = "New Email"; email["description"] = "Email Description"; var parties = []; //ActivityParty (From) var sender = {}; sender["partyid_systemuser@odata.bind"] = "/systemusers(" + OwnerGuid + ")"; sender["participationtypemask"] = 1; //From //ActivityParty (To) var receiver = {}; receiver["partyid_account@odata.bind"] = "/accounts(" + AccountId + ")"; receiver["participationtypemask"] = 2; //To //add this to collection parties.push(sender); parties.push(receiver); email["email_activity_parties"] = parties; var service = new XMLHttpRequest(); service.open("POST", webapiPath, false); service.setRequestHeader("Accept", "application/json"); service.setRequestHeader("Content-Type", "application/json; charset=utf-8"); service.setRequestHeader("OData-MaxVersion", "4.0"); service.setRequestHeader("OData-Version", "4.0"); service.send(JSON.stringify(email)); if (service.readyState == 4 /* complete */) { if (service.status == 204) { } } }ActivityParty entity : https://msdn.microsoft.com/en-us/library/gg328549.aspx
Friday, 20 May 2016
Create Activity and associated Activity Party in Microsoft Dynamics CRM 2016 using Web API
Subscribe to:
Post Comments (Atom)
Read only field , get latest value from read only field in in power app portal
Below line is used to make field readonly in power app portal through js $( "#bdo_relationshiprole_name" ).parent().css( "po...
-
To Query MS CRM DB there are the two distinct ways. Using QueryExpression Using FetchXML Limitation of the QueryExpression is , If yo...
-
In the following code actionName is the name of action. primarycontact and parentaccount is the entityreference attribute in action. nam...
-
To retrieve meta data of global optionSet in Web API, first you will need to retrieve meta data id of option Set. So i create two functi...
No comments:
Post a Comment