作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我有一个 CRM 集成,它向潜在客户和联系人添加了两个字段。一个整数和一个 bool 值。当我们将线索转换为联系人时,我希望线索中的那些自定义字段可以转移到新联系人。我们有超过 700 个实例使用我们的产品,因此这需要一个程序化的解决方案。这就是问题所在。我一直无法理解 CreateAttributeMappings 类,希望这里有人能启发我并告诉我哪里是愚蠢的...
现在我有这样的东西:
var parentEntityMapId = new v4.Sdk.Lookup();
parentEntityMapId.name = "lead";
parentEntityMapId.Value = Guid.NewGuid();
var entityMapId = new v4.Sdk.Lookup();
entityMapId.name = "contact";
//entityMapId.Value = new Guid("608861bc-50a4-4c5f-a02c-21fe1943e2cf");
entityMapId.Value = Guid.NewGuid();
var attributeMapId = new v4.Sdk.Key();
attributeMapId.Value = Guid.NewGuid();
var attributeMap = new v4.SdkTypeProxy.attributemap();
attributeMap.attributemapid = attributeMapId;
attributeMap.entitymapid = entityMapId;
attributeMap.sourceattributename = fieldNameFrom;
attributeMap.targetattributename = fieldNameTo;
//parentEntityMapId.Value = new Guid("DC6574CB-92CE-446C-A5D6-885A75107D52");
attributeMap.parentattributemapid = parentEntityMapId;
var targetAttributeMap = new v4.SdkTypeProxy.TargetCreateAttributeMap();
targetAttributeMap.AttributeMap = attributeMap;
var attributeMapCreateRequest = new v4.SdkTypeProxy.CreateRequest();
attributeMapCreateRequest.Target = targetAttributeMap;
var response = this.CrmService.Execute(attributeMapCreateRequest);
但是这给了我这个错误信息:
0x80046203 映射无效。属性不可映射,或者属性属于不同类型,或者目标属性的大小小于源属性的大小。 平台
如果您能给我任何帮助或见解,我们将不胜感激。
最佳答案
终于明白了。需要拉现有的实体映射,然后只需添加两个字段并发送请求。如此简单的事情是如此令人沮丧......
public void CreateAttributeMapping(string fieldNameFrom, string entityNameFrom, string fieldNameTo, string entityNameTo)
{
var entityMap = Retrieve("entitymap", new List<FilterCriteria> { new FilterCriteria("targetentityname", entityNameTo), new FilterCriteria("sourceentityname", entityNameFrom) }, null);
var entityMapId = new v4.Sdk.Lookup();
entityMapId.name = entityMap.GetKeyName();
entityMapId.Value = entityMap.GetKeyValue();
var attributeMap = new v4.SdkTypeProxy.attributemap();
attributeMap.entitymapid = entityMapId;
attributeMap.sourceattributename = fieldNameTo;
attributeMap.targetattributename = fieldNameFrom;
var targetAttributeMap = new v4.SdkTypeProxy.TargetCreateAttributeMap();
targetAttributeMap.AttributeMap = attributeMap;
var attributeMapCreateRequest = new v4.SdkTypeProxy.CreateRequest();
attributeMapCreateRequest.Target = targetAttributeMap;
var response = this.CrmService.Execute(attributeMapCreateRequest);
关于c# - 以编程方式为潜在客户/联系人实体上的自定义字段创建属性映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8392277/
我是一名优秀的程序员,十分优秀!