Asked by:
how to create record using soap in dynamics crm 2013

Question
-
i tried the below code in dynamics crm online 2013.
function new_record() { debugger; var firstname = "srini"; var lastname = "hsk"; var donotbulkemail = "true"; var address1_stateorprovince = "CHD"; var address1_postalcode = "160036"; var address1_line1 = "#1429/2"; var address1_city = "Chandigarh"; var authenticationHeader = GenerateAuthenticationHeader(); // Prepare the SOAP message. var xml = "<?xml version='1.0' encoding='utf-8'?>" + "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" + authenticationHeader + "<soap:Body>" + "<Create xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" + "<entity xsi:type='contact'>" + "<address1_city>" + address1_city + "</address1_city>" + "<address1_line1>" + address1_line1 + "</address1_line1>" + "<address1_postalcode>" + address1_postalcode + "</address1_postalcode>" + "<address1_stateorprovince>" + address1_stateorprovince + "</address1_stateorprovince>" + "<donotbulkemail>" + donotbulkemail + "</donotbulkemail>" + "<firstname>" + firstname + "</firstname>" + "<lastname>" + lastname + "</lastname>" + "</entity>" + "</Create>" + "</soap:Body>" + "</soap:Envelope>"; // Prepare the xmlHttpObject and send the request. var xHReq = new ActiveXObject("Msxml2.XMLHTTP"); xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false); xHReq.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Create"); xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xHReq.setRequestHeader("Content-Length", xml.length); xHReq.send(xml); // Capture the result var resultXml = xHReq.responseXML; // Check for errors. var errorCount = resultXml.selectNodes('//error').length; if (errorCount != 0) { var msg = resultXml.selectSingleNode('//description').nodeTypedValue; alert(msg); } }
could you anybody clarify me
hsk srinivas
Wednesday, June 18, 2014 12:36 PM
All replies
-
Hi,
Why don't you use the REST api to create records in Dynamics CRM 2013? It's easier to do so. Have a look here : http://msdn.microsoft.com/en-in/library/gg334427.aspx
- Proposed as answer by Guido PreiteMVP Wednesday, June 18, 2014 12:56 PM
Wednesday, June 18, 2014 12:41 PM -
Your code is not working because it uses CRM 4.0 endpoints that are not supported anymore with CRM 2013.
You can use the REST endpoint if you want to create a record with JavaScript.
Check this msdn article: http://msdn.microsoft.com/en-us/library/gg309549.aspx
My blog: www.crmanswers.net - Rockstar 365 Profile
- Proposed as answer by Guido PreiteMVP Wednesday, June 18, 2014 12:56 PM
Wednesday, June 18, 2014 12:41 PM -
i done with the odata/rest.but i'm unable to create record using soap.how to do that plz clarify me.i searched some other blogs also
hsk srinivas
Wednesday, June 18, 2014 12:45 PM -
If you want to make your life harder and use SOAP messages, here an example with SOAP for CRM 2011
http://mileyja.blogspot.fi/2011/04/create-requests-in-net-and-jscript-in.html
My blog: www.crmanswers.net - Rockstar 365 Profile
- Proposed as answer by Guido PreiteMVP Wednesday, June 18, 2014 12:56 PM
Wednesday, June 18, 2014 12:49 PM -
odata has some limitations.i'm new to soap.i'm getting error at generateauthenticationheader() undefined.above links are not undertanding.could anybody modify that code.
hsk srinivas
Wednesday, June 18, 2014 1:27 PM -
As I wrote before your code is for CRM 4.0, it is not supported inside CRM 2013. You can trash it and start from the example of the blog I linked.
My blog: www.crmanswers.net - Rockstar 365 Profile
Wednesday, June 18, 2014 1:39 PM -
ok, thanks for suggesting.
hsk srinivas
Wednesday, June 18, 2014 1:42 PM -
Also ms crm SDK comes to a very good applicaiotion Soaplogger, where you can write your server side code and it will help you to generate soap code from it.
Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.Thursday, June 19, 2014 4:59 AMModerator