在Dynamics 365 CRM中创建线索和销售文献之间的关系。

问题描述 投票:0回答:1

我刚刚得到一个asp.net webforms应用程序的要求,它必须与MS Dynamics 365 CRM集成。我从来没有做过Dynamics 365的开发,但无论如何,我已经设法使用.net sdk与CRM连接,并创建了一个铅和销售文献实体。我的意图是通过去实现我们可以做什么 Dynamics 365 portal --> Lead --> related --> Activities--> Sales Literature:

enter image description here

所以,我想用.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: 'The Entity Relationship with SchemaName = 'SalesLiterature_Lead' not found in MetadataCache'。

System.ServiceModel.FaultException`1: "The Entity Relationship with SchemaName = 'SalesLiterature_Lead' was not found in the MetadataCache'

我已经检查了两个 牵头实体参考销售文献实体参考 但找不到这个关系的Schema名称。是我错过了什么,还是这是不可能的?

c# dynamics-crm dynamics-365 dynamics-365-sales
1个回答
1
投票

我坚信你截图中显示的 "销售资料 "是一个自定义的活动实体,它与OOB "销售资料 "实体不同。

要创建一个以Lead为对象的自定义实体(活动),请使用以下方法 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);
© www.soinside.com 2019 - 2024. All rights reserved.