C# 进口合同
正在尝试将合同从本地主机导入到联机主机。我调整了SDK解决方案“dataimport”,但是在所需的查找属性C# 进口合同,c#,dynamics-crm-2011,C#,Dynamics Crm 2011,正在尝试将合同从本地主机导入到联机主机。我调整了SDK解决方案“dataimport”,但是在所需的查找属性CustomerIdName方面遇到了问题。它给 错误2147220654“找到重复的查找引用” 另一个到lookup属性contracttemplateid的映射工作正常。我认为这与这样一个事实有关,即它可以映射到帐户或联系人实体。源文件(仅1个记录行)和下面的代码。这是基于sdk解决方案中包含的ImportWithCreate类的1列映射 title,activeon,allotmen
CustomerIdName
方面遇到了问题。它给
错误2147220654“找到重复的查找引用”
另一个到lookup属性contracttemplateid
的映射工作正常。我认为这与这样一个事实有关,即它可以映射到帐户
或联系人
实体。源文件(仅1个记录行)和下面的代码。这是基于sdk解决方案中包含的ImportWithCreate
类的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
我以前没有像那样编写自己的数据导入脚本,但我看到了这个错误 我怀疑这可能是因为您有两个名为“USF Admin”的联系人/帐户 它试图为查找字段找到唯一的记录,如果有重复记录,它不知道该设置哪个
您还可以尝试使用标准CRM数据导入工具手动执行数据导入,这可能有助于您缩小代码或数据中出现问题的范围。无重复项。Microsoft支持人员能够通过注释掉特定查找映射的代码块来解决此问题 //LookUpMapping currentLookUpMapping=新建LookUpMapping()
#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