1
votes

I need to automate the Dynamics CRM Import Wizard that currently lets you zip up Accounts and Contacts files together and import them into CRM all at once as per the screen shot below.

enter image description here

We have quite a few zip files to import so thought it might be wise to automate this using the Dynamics CRM SDK. Looking in the SDK I can find an example of importing entity files 1 by 1 such as here but no examples of importing them together in a zip file? Is this possible and if so are there any examples of this? For instance the SDK code below looks at an "Import Accounts.csv" file only but I really need something to handle an "Import Accounts and Contacts.zip".

// Create Import File.
ImportFile importFile = new ImportFile()
{
    Content = BulkImportHelper.ReadCsvFile("Import Accounts.csv"), // Read contents from disk.
    Name = "Account record import",
    IsFirstRowHeader = true,
    ImportMapId = new EntityReference(ImportMap.EntityLogicalName, importMapId),
    UseSystemMap = false,
    Source = "Import Accounts.csv",
    SourceEntityName = "Account_1",
    TargetEntityName = Account.EntityLogicalName,
    ImportId = new EntityReference(Import.EntityLogicalName, importId),
    EnableDuplicateDetection = false,
    FieldDelimiterCode =
        new OptionSetValue((int)ImportFileFieldDelimiterCode.Comma),
    DataDelimiterCode =
        new OptionSetValue((int)ImportFileDataDelimiterCode.DoubleQuote),
    ProcessCode =
        new OptionSetValue((int)ImportFileProcessCode.Process)
};
1

1 Answers

0
votes

According to this enum, the only options available for programmatic importing are xml and csv. Have your code open each zip and submit each file individually.

Update based on your comment: Disregard the enum. I was hunting around the SDK for import related stuff and thought that enum was relevant. Digging a little deeper, the metadatabrowser shows me that the importfile entity's filtetypecode optionset only has the following options: CSV, XML Spreadsheet 2003, Attachment, and XLSX. So I'm guessing that the handling of zip files is baked into the dialog as opposed to the platform. In other words, I think you're right, programmatic importing of zips is not looking good.