0

我刚刚收到了对 asp.net webforms 应用程序的需求,它必须与 MS Dynamics 365 CRM 集成。我从来没有为 Dynamics 365 做过开发,但无论如何我已经设法使用 .net sdk 连接到 CRM 并创建了一个潜在客户和销售文献实体。我的意图是通过以下方式实现我们可以做的事情Dynamics 365 portal --> Lead --> related --> Activities--> Sales Literature

在此处输入图像描述

因此,我想使用 .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);

但是代码无法建立这样的关系CRMService.Execute(association);

System.ServiceModel.FaultException`1:“在 MetadataCache 中找不到与 SchemaName = 'SalesLiterature_Lead' 的实体关系”

我检查了潜在客户实体参考销售文献实体参考,但没有找到此关系的架构名称。我错过了什么或者这是不可能的吗?

4

2 回答 2

1

我坚信您的屏幕截图中显示的“销售文学”是一个自定义活动实体,它与 OOB“销售文学”实体不同。

regardingobjectid使用此代码创建具有潜在客户的自定义实体(活动) 。只需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);
于 2020-05-05T18:24:19.513 回答
0

此错误向您表明您的关系名称错误,因此您应该找到正确的关系名称。因此您需要进行 CRM 自定义并在关系中的 SalesLiterature 实体下找到正确的架构名称

于 2020-07-12T10:04:04.597 回答