以编程方式为潜在客户/联系人实体上的自定义字段创建属性映射
因此,我有一个 CRM 集成,它向潜在客户和联系人添加了两个字段。一个整数和一个布尔值。当我们将潜在客户转换为联系人时,我希望潜在客户中的这些自定义字段能够转移到新联系人。我们有超过 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 映射无效。属性不可映射,或者属性属于不同类型,或者目标属性的大小小于源属性的大小。 平台
如果您能给我任何帮助或见解,我将不胜感激。
So I have a CRM integration that adds two fields to the lead and contact. An integer and a Boolean. When we convert a lead into a contact I want those custom fields from the lead to carry over to the new contact. We have over 700 instances using our product so this needs to be a programmatic solution. And thats where the problem lies. I haven't been able to wrap my head around the CreateAttributeMappings class and was hoping someone here could enlighten me and show me where I'm being dumb...
Right now I've got something like this:
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);
However this gives me this error message:
0x80046203
Invalid mapping. Either an attribute is not mappable, or attributes are of different types, or the size of the target attribute is smaller than the size of the source attribute.
Platform
Any help or insight you could give me would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
终于想通了。需要拉取现有的实体映射,然后只需添加两个字段并发送请求。如此简单的事情却如此令人沮丧……
Finally figured it out. Need to pull the existing entity map and then just add the two fields and send the request. Something so simple was so frustrating...
我不能说我自己以编程方式完成了此操作,但在创建链接两个实体之间的字段的
attributemap
方面,您所做的事情看起来是正确的。您得到的错误将是两件事之一。
它匹配的属性映射字段的大小或类型可能不同。如果您说您的集成负责创建,那么这似乎不太可能,但通过界面进入 CRM 可能是值得的。查找潜在客户和联系人之间的关系,然后手动添加映射以查看是否出现相同的错误。
如果确实出现错误,则说明存在不同的情况(类型或大小)。
如果您没有收到错误,则意味着您尝试执行的操作是正确的,但是代码中在尝试创建的属性映射方面会出现问题。
在这种情况下,可能值得进行调试以了解更多信息。然后,如果您查看尝试通过代码设置的值,并与手动输入的数据库中现有的值进行比较,它可能会指出缺少的内容。
I can't say i've done this programmatically myself but what your doing looks correct in terms of creating an
attributemap
which links the fields across both entities.The error your getting will be one of two things.
The attributemaps fields it's matching from and to may differ either in size or type. This is seems unlikely if you say your integration takes care of the creation but it's probably worth going into CRM through the interface. Finding the relationship between lead and contact, then adding the mapping manually to see if you get the same error.
If you do get an error, then there is something different(type or size).
If you don't get the error, then it means what your trying to do is correct, however there will be an issue in the code somewhere in terms of the attribute map it is trying to create.
In which case it may be worth debugging through to find out more. Then if you look at the values you are trying to set through code, and compare to the one that would now exist in the database from your manual entry it may point to what's missing.
我们可以使用 PowerShell 来完成此操作:
We could do this using PowerShell: