Home › Dynamics 365 Customer Engagement (CRM) › Create Record in Dynamics 365 using jQuery
Dynamics 365 Customer Engagement (CRM) · Jul 9, 2016

Create Record in Dynamics 365 using jQuery

To create a new record of an entity in Dynamics 365, use the code below:

var account = {};
account.Name = "Sample Account";
var jsonAccount = window.JSON.stringify(account);

if (typeof($) === 'undefined') {
 $ = parent.$;
 jQuery = parent.jQuery;
}

$.ajax({
 type: "POST",
 contentType: "application/json; charset=utf-8",
 datatype: "json",
 url: Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/AccountSet",
 data: jsonAccount,
 beforeSend: function (XMLHttpRequest) {
 //Specifying this header ensures that the results will be returned as JSON.
 XMLHttpRequest.setRequestHeader("Accept", "application/json");
 },
 success: function (data, textStatus, XmlHttpRequest) {
 account = data.d;
 alert("Success");
 },
 error: function (XMLHttpRequest, textStatus, errorThrown) {
 errorHandler(XMLHttpRequest, textStatus, errorThrown);
 }
});

This will create the account in Dynamics 365:

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Carl de Souza
KEEP LEARNING. KEEP BUILDING.

Explore AI, agents & Microsoft technology.

I share practical ideas, tutorials, and videos about AI, AI agents, Microsoft technologies, and the Power Platform.