Data import using SDK results in failed import but no error messages

Question Status

AK350 asked a question on 26 Jul 2013 6:30 AM

I am trying to do a data import as an automated process using the SDK, but the import overall shows up with a failed status even though the parse, transform, and import jobs all succeed without errors.  I'm using CRM Online 2011 UR12.  I've looked over the data import sample project in the SDK and read the MSDN documents related to data import, but these all seem to be lacking in details.  I have a data map that was built using an advanced find in CRM, that was exported and opened in excel where I put data into the file.  I then set up an app to import the file using the SDK, the import and the individual steps of the import all show up, including the record count, but the record counts on the job are as follows: Successes: 0, Partial Failures: 0, Failures: 0, Total Processed: 720.  The XML source file should be fine, I can take a file with the exact same format, just different records, and it will import fine using the CRM import wizard.  I attached a file to this post containing the code I used to do the import.  Also, here are some screenshots of what the import looks like in CRM:

These are the Import File Parse, Transform Parse Data, and Import jobs:

Does anyone know what might be causing this to fail?  Any ideas or suggestions would be helpful.  Thanks!

rumcajs responded on 30 Jul 2013 5:35 AM

were you able to solve this? I am facing this problem too...thanks

AK350 responded on 30 Jul 2013 5:49 AM

I don't have an answer yet, I have an open support ticket with Microsoft but I'm waiting for them to get back to me.  In the mean time, I've gone down the path of using the ExecuteMultipleRequest to create a bunch of records in batch.  I ran only a couple of tests with that, so I don't know where the record limit is, but at 500 records it seems to be working very well.  The only drawback to this process is that you can't import records with an inactive status as you could do with the data import.  The workaround would be to do a separate ExecuteMultipleRequest do update all the statuses to inactive after the records are created.

I'll post again when I get an answer from Microsoft.

rumcajs responded on 30 Jul 2013 8:23 AM

Hi ak350,

I resolved my problem. I checked mapping file

and found following rows


   <EntityMap TargetEntityName="myTargetEntity" SourceEntityName="mySource" Dedupe="Ignore" ProcessCode="Process">

In my code for import I was creating import file

               Entity importFile = new Entity("importfile");

               importFile.Attributes.Add("targetentityname", myTargetEntity);

               importFile.Attributes.Add("sourceentityname", differentSourceEntity);

I found out that I had different source entity name in my code and different in mapping file. So maybe it will be helpful also for you to check if your map file and code matches. It is really bad that CRM shows that everything goes well and result is failure with no trace to mistakes.

Probably your mistake will be different but hopefully my discover could lead you to find it.

In overall when you are able to import your data manualy using same Mapping Xml problem must be in the code which does import.

Gayatri Shevde responded on 21 Jul 2014 4:20 PM

Hello Rumcgs,

I would suggest you to create the ticket with Support to get your questions answered eveything

Gayatri Shevde responded on 21 Jul 2014 4:26 PM

Here I would suggest you to create a Ticket with the syouurt

JustinLofquist responded on 19 Sep 2015 8:13 AM

The ImportFile sourceEntityName property must be the same as the ImportMap sourceEntityName property.  That value can be retrieved with the following code:

               var query = new QueryExpression(ImportEntityMapping.EntityLogicalName) { ColumnSet = new ColumnSet("sourceentityname") };

               query.Criteria.AddCondition(new ConditionExpression("importmapid", ConditionOperator.Equal, importMapId));

               var result = serviceProxy.RetrieveMultiple(query);

               return result.Entities.Select(c => c.ToEntity<ImportEntityMapping>()).First().SourceEntityName;