可以使用 XRM SDK 将帖子插入动态 CRM 社交窗格帖子吗?

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

我正在使用 Microsoft.Xrm.Sdk 与 Dynamics CRM On-Premise 进行交互。我想要做的是通过 API 将帖子插入到 Lead 实体社交窗格帖子中。

我所做的如下:

var _crmUrl = _configuration.GetSection("Crm:Url").Value;
var _organizationName = _configuration.GetSection("Crm:Org").Value;
var clientCredentials = new System.ServiceModel.Description.ClientCredentials();
clientCredentials.Windows.ClientCredential.UserName = _configuration.GetSection("Crm:user").Value;
clientCredentials.Windows.ClientCredential.Password = _configuration.GetSection("Crm:pass").Value;
var crm = new OrganizationServiceProxy($"{_crmUrl}{_organizationName}", clientCredentials.Windows.ClientCredential);
Microsoft.Xrm.Sdk.Query.ColumnSet columns = new Microsoft.Xrm.Sdk.Query.ColumnSet() { AllColumns = true };
var entity = await crm.RetrieveAsync("lead", new Guid(model.Id), columns, CancellationToken.None);

// INSERT POST TO entity

await crm.UpdateAsync(entity, CancellationToken.None);

可以使用XRM SDK插入帖子吗?

c# dynamics-crm dynamics-365-ce-onpremises
1个回答
0
投票

是的,这是可能的! 您要查找的架构名称是

post

创建新的

post
记录应该很简单,因为您已经拥有连接:

var crm = new OrganizationServiceProxy(...);
var entity = await crm.RetrieveAsync("lead", new Guid(model.Id), columns, CancellationToken.None);

继续此操作,您可以创建新的

post
记录:

var postData = new Entity("post");
postData["text"] = "This is an automatic post from a plugin!";
postData["source"] = 1;
postData["regardingobjectid"] = new EntityReference("lead", entity.Id);

source
列指的是
post
是自动创建还是手动创建。请参阅 Microsoft 文档

然后保存记录

crm.Create(postData);
© www.soinside.com 2019 - 2024. All rights reserved.