添加注释

时间:2011-11-15 20:29:15

标签: dynamics-crm dynamics-crm-4 dynamics-crm-2011

我正在尝试通过代码添加注释,并且注释添加正常,但它不会添加正确的CreatedBy用户。它只是添加注释并将createdby用户设置为admin。这就是我正在使用的:

Entity annotation = new Entity("annotation");
annotation["createdby"] = new EntityReference("systemuser", new Guid("2a213502-db00-e111-b263-001ec928e97f"));
annotation["objectid"] = new EntityReference("opportunity", opportunityId);
annotation["subject"] = "Lead Note";
annotation["notetext"] = p.Column_18;
Guid annotationId = lService.Create(annotation);

您是否需要做一些特别的事情才能添加CreatedBy?

谢谢!

1 个答案:

答案 0 :(得分:3)

您无法在“创建”或“更新”中设置“已创建”。请参阅属性createdby的说明。它对创建或更新无效。系统会将此属性设置为正在执行当前请求的用户。

您必须使用模拟以其他用户的名义创建记录。因此,您必须将CallerId属性设置为您要模拟的标识的用户的ID。见Impersonate Using the ActOnBehalfOf Privilege

相关问题