Asked by:
XML to CRM Record

Question
-
Hi Folks,
Scenario: I have a XML file as below
<?xml version="1.0" encoding="utf-8"?>
<NewDataSet xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="generic">
<PRODUCT InstrumentType="BykMac" ShortName="ABP">
</PRODUCT>
</NewDataSet>The above XML file is placed in C: drive, I have a custom web application where on a click of button I should get this XMl file read the dat "InstrumentType" and "ShortName" and create a record in MSCRM 2011 for "XYZ" entity.
Thanks in advance
Regards,
Nandan S
Tuesday, April 22, 2014 6:29 AM
All replies
-
Hi,
I am assuming you are using ms crm onpremise, Please download SDK it have sample code for how to use iorganization service. You can create your entity object and set properties from your xml object can create it in CRM.
You can check this as well for your reference : http://msdn.microsoft.com/en-us/library/gg695790.aspx
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.- Edited by HIMBAPModerator Tuesday, April 22, 2014 6:34 AM
Tuesday, April 22, 2014 6:33 AMModerator -
Hi Mahender ,
Thanks for response , and u r rite it is MSCRM 2011 onpremise.
I have code to create entity object , but I dnt know how to set properties from XML . Can u please help me with code for the above XML
Regards,
Nandan S
Tuesday, April 22, 2014 6:41 AM -
Hi,
You can serializ your xml data in .net class and can read values from there and set in your entity.
http://www.codeproject.com/Articles/10429/Convert-XML-data-to-object-and-back-using-serializ
Hope it will help.
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.Tuesday, April 22, 2014 6:52 AMModerator -
Use LINQ to XML, it will much simpler and faster to read through XML
MaKeer | myencounterwithcrm.wordpress.com | CRM2011 User Settings Utility | CRM2011 Lookup Preview | CRM2011 Lookup Attribute Mapping | CRM2011 TreeView Control (Beta) | CRM2011 N:N Entity View (Beta) | CRM 2011 Global Quick Search (Beta)
Friday, April 25, 2014 6:39 PM -
HI Nandan,
you can use the following code to achieve this.
Entity xyz = new Entity("xyz"); XmlDocument doc = new XmlDocument(); doc.Load(@"C:\name.xml"); foreach (XmlNode node in doc.SelectNodes("//PRODUCT[@ShortName]")) { xyz["shortname"]=node.Attributes["ShortName"].Value; _service.Create(xyz); }
Thanks and Regards. Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.
- Proposed as answer by Ravitheja J Saturday, April 26, 2014 8:16 AM
Saturday, April 26, 2014 8:15 AM