简体   繁体   English

在 Dynamics 365 CRM 中创建潜在客户和销售文献之间的关系

[英]Creating Relationship between a lead and sales literature in Dynamics 365 CRM

I just got a requirement for asp.net webforms app, which has to integrate with MS Dynamics 365 CRM.我刚收到 asp.net webforms 应用程序的需求,它必须与 MS Dynamics 365 CRM 集成。 I have never done dev for Dynamics 365 but anyhow I've managed to connect with CRM using .net sdk and created a Lead and Sales Literature entity.我从来没有为 Dynamics 365 做过开发,但无论如何我已经设法使用 .net sdk 连接到 CRM 并创建了一个潜在客户和销售文献实体。 My intent is to achieve what we can do by going to Dynamics 365 portal --> Lead --> related --> Activities--> Sales Literature :我的意图是通过转到Dynamics 365 portal --> Lead --> related --> Activities--> Sales Literature来实现我们可以做的事情:

在此处输入图像描述

So, I want to establish relationship between these two entities (lead and sales literature) using .net sdk, here is my code:因此,我想使用 .net sdk 建立这两个实体(潜在客户和销售文献)之间的关系,这是我的代码:

 AssociateRequest association = new AssociateRequest

            {

                Target = new EntityReference(leadEntity.LogicalName, leadid),

                RelatedEntities = new EntityReferenceCollection

                {


                 new EntityReference(SLEntity.LogicalName, SLID)
                },

                Relationship = new Relationship("Lead_SalesLiterature"),
                RequestId = new Guid()
            };

           // Execute the request.

           CRMService.Execute(association);

But the code fails to establish the relationship on CRMService.Execute(association);但是代码无法在CRMService.Execute(association); saying that:说:

System.ServiceModel.FaultException`1: 'The Entity Relationship with SchemaName = 'SalesLiterature_Lead' was not found in the MetadataCache' System.ServiceModel.FaultException`1:“在 MetadataCache 中找不到与 SchemaName = 'SalesLiterature_Lead' 的实体关系”

I have checked both Lead Entity Reference and Sales Literature Entity Reference but not finding Schema name for this relationship.我检查了潜在客户实体参考销售文献实体参考,但没有找到此关系的架构名称。 Am I missing something or this is not possible?我错过了什么或者这是不可能的吗?

I strongly believe that the "Sales Literature" showed in your screenshot is a custom activity entity, and it's not the same as OOB "Sales Literature" entity.我坚信您的屏幕截图中显示的“销售文学”是一个自定义活动实体,它与 OOB“销售文学”实体不同。

To create a custom entity (activity) with a Lead as regardingobjectid can be done using this code.可以使用此代码来创建一个自定义实体(活动),并将其作为regardingobjectid objectid 的潜在客户。 Just replace the task with your entity name只需将task替换为您的实体名称

           Entity followup = new Entity("task");
           followup["subject"] = "Sample task - an activity";
           followup["description"] = "Sample description";

           followup["scheduledstart"] = DateTime.Now;
           followup["scheduledend"] = DateTime.Now.AddDays(2);

           Guid regardingobjectid = new Guid("26ADDD07-D9F4-E711-8138-E0071B715B11"); //leadid
           string regardingobjectidType = "lead";
           followup["regardingobjectid"] = new EntityReference(regadingobjectidType,regardingobjectid);

           // Create the followup activity
           CRMService.Create(followup);

this error show to you that your relation name is wrong so you should find correct relation name.so you need to go CRM customization and under the SalesLiterature entity in relationships find correct schema name此错误向您表明您的关系名称错误,因此您应该找到正确的关系名称。因此您需要 go CRM 自定义并在关系中的 SalesLiterature 实体下找到正确的架构名称

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM