I'm trying to import a CSV file to update existing records. Right now I get "The File Type is Invalid" whenever this runs.
I'm basing this off the example code in: sdk\samplecode\cs\datamanagement\dataimport
I added a column "Account" at the beginning of the CSV: "Import Accounts.csv"
Account,src_name,src_parent,src_addresstype
5C1ED238-5837-E311-B443-000C2947CEBC,A. Datum Corporation2,Adventure Works,bill
5E1ED238-5837-E311-B443-000C2947CEBC,Adventure Works2,,ship
601ED238-5837-E311-B443-000C2947CEBC,Blue Yonder Airlines2,,bill
621ED238-5837-E311-B443-000C2947CEBC,City Power & Light2,A. Datum Corporation,bill
641ED238-5837-E311-B443-000C2947CEBC,"Fabrikam, Inc.2",Adventure Works,ship
I added this column mapping:
#region Column Zero Mappings // Create a column mapping for a 'text' type field. ColumnMapping colMapping0 = new ColumnMapping() { // Set source properties. SourceAttributeName = "Account", SourceEntityName = "Account_1", // Set target properties. TargetAttributeName = "accountid", TargetEntityName = Account.EntityLogicalName, // Relate this column mapping with the data map. ImportMapId = new EntityReference(ImportMap.EntityLogicalName, importMapId), // Force this column to be processed. ProcessCode = new OptionSetValue((int)ColumnMappingProcessCode.Process) }; // Create the mapping. Guid colMappingId0 = _serviceProxy.Create(colMapping0); #endregion
I also updated the code that creates the import to be .Update instead of .Create
// Create Import Import import = new Import() { // IsImport is obsolete; use ModeCode to declare Create or Update. ModeCode = new OptionSetValue((int)ImportModeCode.Update), Name = "Importing data" };
Any thoughts on how to fix this? Or how to submit data for updating existing records?
I've tried using the built-in feature of exporting the "Re-importable XML file, however that doesn't help with the particular way we need to put updated data in the system.
Thanks