【问题标题】:How to update the Owner of a Case/Incident record如何更新案例/事件记录的所有者
【发布时间】:2013-05-29 14:11:44
【问题描述】:

我正在编写一个针对事件记录运行的工作流活动。该活动旨在将 ownerid 从用户更改为用户所属的团队。我已经成功找回了这个团队。 OwnerId 字段是标准的 Owner 类型。我尝试了以下方法:

if (results.Entities.Count > 0)
{
    var er = new EntityReference("team",new Guid(results[0].Attributes["teamid"].ToString()));
    er.Name = results[0].Attributes["name"].ToString();
    updatedEnquiry.OwnerId = er;
    Service.Update(updatedEnquiry);
}

results 是一个 EntityCollection 服务是一个 IOrganizationService

事件、团队和用户实体是开箱即用的 CRM 2011 实体。

在事件记录的工作流结束后,所有者没有改变。

如何使用新数据更新此所有者字段?

【问题讨论】:

  • 很明显,这是因为您正在阅读您真正想要结果的结果;)
  • 嗯,让我们把它归结为在 SO 编辑器中没有 Intellisense。

标签: dynamics-crm-2011


【解决方案1】:

要更新所有者,您需要使用AssignRequest,而不必为EntityReference 指定name 属性

// incidentId holds the record ID Guid to update

if (results.Entities.Count > 0)
{
    // get the right team
    Entity team = results.Entities[0];

    AssignRequest assignRequest = new AssignRequest
        {
            Assignee = new EntityReference("team", team.Id),
            Target = new EntityReference("incident", incidentId)
        };
    Service.Execute(assignRequest);
}

【讨论】:

  • 这与我昨天晚些时候发布的内容几乎相同。我正要发布我自己的答案,但你打败了我。感谢您的帮助和 +1
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-12
  • 2022-09-28
  • 2021-09-03
  • 1970-01-01
相关资源
最近更新 更多