locked
Importing records into a custom entity via SDK code RRS feed

  • Question

  • 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.


    Tuesday, August 5, 2014 10:24 AM

Answers

  • Hi,

    the screenshot is not visible, try to upload it (for example tinypic) and refer the link.

    However from your description looks like you are using early bound (you mentioned intellisense working for some classes) in this case you need to regenerate the early bound classes using crmsvcutil.exe or use late bound style


    My blog: www.crmanswers.net - Rockstar 365 Profile

    Tuesday, August 5, 2014 10:36 AM

All replies

  • Hi,

    the screenshot is not visible, try to upload it (for example tinypic) and refer the link.

    However from your description looks like you are using early bound (you mentioned intellisense working for some classes) in this case you need to regenerate the early bound classes using crmsvcutil.exe or use late bound style


    My blog: www.crmanswers.net - Rockstar 365 Profile

    Tuesday, August 5, 2014 10:36 AM
  • Running CRMSVCUTIL.EXE and incorporating the output into my project solved the problem.

    Thanks

    John

    Tuesday, August 5, 2014 11:26 AM