尝试将合同从本地导入到在线主机。我调整了 SDK 解决方案“dataimport”,但是在使用所需的查找属性时遇到了问题CustomerIdName
。它给
错误 2147220654 “找到重复的查找引用”
另一个到查找属性的映射contracttemplateid
工作得很好。我认为这与它可以映射到实体account
或contact
实体的事实有关。源文件(只有 1 个记录行)和下面的代码。这是基于ImportWithCreate
sdk 解决方案中包含的类的 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