Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

Unable to Create a lead records by radio button clicks in html page in mscrm 2015 online

$
0
0

Hi 

 I am create a html page  in this more than 6 radio buttons are there like as Create or update or delete or read etc.. once select the "Create" Radio button  than clicks "Save Button"  the select records will be created.

i am wrote a code ajax in html for record creation  .Error is  showing as failure.

i work on this code full day still now i am not trouble shoot the is . Please fix the issue.

Code:

<script src="json2.js"></script>

<script src="mage_jquery2.1.1.min.js"></script>
<script src="../ClientGlobalContext.js.aspx" type="text/javascript"></script>
<script type="text/javascript">

function Create_PortalUser() {
debugger;

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

var serverUrl = document.location.protocol + "//" + document.location.host + "/" + Xrm.Page.context.getOrgUniqueName();

if (document.getElementById('r1').checked) {
//Create Lead Record
try {

var ODATA_ENDPOINT =Xrm.Page.context.prependOrgName("/xrmservices/2011/organizationdata.svc") ;
var CRMObject = new Object();
var ODATA_EntityCollection = "/LeadSet";
var CRMObject = new Object();
CRMObject.fullname = "TestLead";

//Parse the entity object into JSON
var jsonEntity = window.JSON.stringify(CRMObject);
//Asynchronous AJAX function to Create a CRM record using OData
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: serverUrl + ODATA_ENDPOINT + ODATA_EntityCollection,
data: jsonEntity,
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) {
alert("success");
var NewCRMLeadRecordCreated = data["d"];
alert("CRM GUID created: " + NewCRMLeadRecordCreated.Id); //AccountId is a Primary field in Account Entity.
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("failure");
}
});
}
catch (e) {
alert(e); //debugLog(e);
}
}

}


Viewing all articles
Browse latest Browse all 55831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>