0

尝试将合同从本地导入到在线主机。我调整了 SDK 解决方案“dataimport”,但是在使用所需的查找属性时遇到了问题CustomerIdName。它给

错误 2147220654 “找到重复的查找引用”

另一个到查找属性的映射contracttemplateid工作得很好。我认为这与它可以映射到实体accountcontact实体的事实有关。源文件(只有 1 个记录行)和下面的代码。这是基于ImportWithCreatesdk 解决方案中包含的类的 1 列映射。

title,activeon,allotmenttypecode,expireson,billingstarton,billingendon,
new_companyorindividual,CustomerIdName, Acme Consulting Company,
5/1/2000,1,1/23/2002,5/1/2000,1/23/2002,0,USF Admin

#region Column Eight Mappings
            // Create a column mapping for a 'lookup' type field.
            ColumnMapping colMapping8 = new ColumnMapping()
            {
                // Set source properties.
                SourceAttributeName = "CustomerIdName",
                SourceEntityName = "Contract_1",

                // Set target properties.
                TargetAttributeName = "customerid",
                TargetEntityName = Contract.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 colMappingId8 = _serviceProxy.Create(colMapping8);

            // Because we created a column mapping of type lookup, we need to specify lookup details in a lookupmapping.
            // One lookupmapping will be for the parent account, and the other for the current record.
            // This lookupmapping is important because without it the current record
            // cannot be used as the parent of another record.

            // Create a lookup mapping to the parent account.  
            LookUpMapping parentLookupMapping8 = new LookUpMapping()
            {
                // Relate this mapping with its parent column mapping.
                ColumnMappingId =
                    new EntityReference(ColumnMapping.EntityLogicalName, colMappingId8),

                // Force this column to be processed.
                ProcessCode =
                    new OptionSetValue((int)LookUpMappingProcessCode.Process),

                // Set the lookup for an account entity by its name attribute.
                LookUpEntityName = Account.EntityLogicalName,
                //LookUpEntityName = Contact.EntityLogicalName,
                LookUpAttributeName = "name",
                LookUpSourceCode =
                    new OptionSetValue((int)LookUpMappingLookUpSourceCode.System)
            };

            // Create the lookup mapping.
            Guid parentLookupMappingId8 = _serviceProxy.Create(parentLookupMapping8);

            // Create a lookup on the current record's "src_name" so that this record can
            // be used as the parent account for another record being imported.
            // Without this lookup, no record using this account as its parent will be imported.
            LookUpMapping currentLookUpMapping8 = new LookUpMapping()
            {
                // Relate this lookup with its parent column mapping.
                ColumnMappingId =
                    new EntityReference(ColumnMapping.EntityLogicalName, colMappingId8),

                // Force this column to be processed.
                ProcessCode =
                    new OptionSetValue((int)LookUpMappingProcessCode.Process),

                // Set the lookup for the current record by its src_name attribute.
                LookUpAttributeName = "CustomerIdName",
                LookUpEntityName = "Contract_1",
                LookUpSourceCode =
                    new OptionSetValue((int)LookUpMappingLookUpSourceCode.Source)
            };

            // Create the lookup mapping
            Guid currentLookupMappingId8 = _serviceProxy.Create(currentLookUpMapping8);
            #endregion
4

2 回答 2

0

没有重复。Microsoft 支持能够通过注释掉该特定代码的 LookUpMapping 代码块来解决问题。

//LookUpMapping currentLookUpMapping = new LookUpMapping()

于 2012-11-12T17:01:15.620 回答
0

我以前没有像以前那样编写自己的数据导入脚本,但是我看到了那个错误。

我怀疑这可能是因为您有两个名为“USF Admin”的联系人/帐户。

它试图为查找字段找到唯一的记录,如果有重复,它不知道要设置哪个。

您也可以尝试使用标准的 CRM 数据导入工具手动执行数据导入,如果代码或数据存在问题,这可能会帮助您缩小范围。

于 2012-11-10T18:21:01.050 回答