Our organisation routinely imports data into our Dynamics CRM 2013 database using code developed from the SDK. Up until now we have only worked with OOB entities (account, contact, etc.), but now want to work with some custom entities. It is possible
using the Import Manager to import this data, but to be honest it is a bit of a slog and we want to make it slicker by doing it programmatically.
The problem comes in the code where the ImportFile is defined. When we get to setting the TargetEntityName, intellisense shows and error when I try to reference the custom entity (see snippet below):
Dim importFile As New ImportFile() With
{
.Content = BulkImportHelper.ReadCsvFile("\\mastersvr\Shares\CRMImport\destination\" & strControlNo & "\ABI_1_project.csv"),
.Name = "ABI Project record import",
.IsFirstRowHeader = True,
.ImportMapId = New EntityReference(ImportMap.EntityLogicalName, importMapId),
.UseSystemMap = False,
.Source = "\\mastersvr\Shares\CRMImport\destination\" & strControlNo & "\ABI_1_project.csv",
.SourceEntityName = "ABI_1_project",
.TargetEntityName = >>>Problem Here>>>project.EntityLogicalName,
.ImportId = New EntityReference(import.EntityLogicalName, importId),
.EnableDuplicateDetection = True,
.FieldDelimiterCode = New OptionSetValue(CInt(Fix(ImportFileFieldDelimiterCode.Comma))),
.DataDelimiterCode = New OptionSetValue(CInt(Fix(ImportFileDataDelimiterCode.DoubleQuote))),
.ProcessCode = New OptionSetValue(CInt(Fix(ImportFileProcessCode.Process)))
}
My question is, how do I reference the custom entity to get this code to work? I have 8 custom entities to work with, so this is no trivial matter.
Thanks in advance for any help.