gpt4 book ai didi

c# - 以编程方式为潜在客户/联系人实体上的自定义字段创建属性映射

转载 作者:行者123 更新时间:2023-11-30 22:33:16 25 4
gpt4 key购买 nike

所以我有一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com