【问题标题】:MS CRM 2011: Auditing feature and Updates via IOrganizationService webserviceMS CRM 2011:通过 IOrganizationService 网络服务进行审计功能和更新
【发布时间】:2011-03-15 16:57:16
【问题描述】:

我们计划使用 CRM 2011 的审计功能来跟踪谁更改了几个实体的哪个内场。 但是如果您通过IOrganizationService 更新实体会发生什么?

例如,假设您的系统中有一个地址实体City="London"Street="Baker Street"。现在,在您的代码中,您为此地址创建了一个实体对象(后期绑定)。您设置了它的 GUID,City="London"Street="Downing Street"!现在您为此实体调用IOrganizationService.Update。 审计功能是否会意识到街道已经改变但城市没有?或者他会告诉我城市发生了变化,而实际上并没有发生变化?

【问题讨论】:

    标签: dynamics-crm-2011


    【解决方案1】:

    审核选择作为更新消息的一部分提交的未更改字段。例如,以下代码将导致审计记录记录对 lastname 属性的更改,尽管提交的值与数据库中的值相同。换句话说,审计是在消息级别执行的,而不是实际将值与数据库进行比较(据我了解,这将是一项非常昂贵的工作)。

    var connection = CrmConnection.Parse("Url=http://localhost/acme;");
    var service = new OrganizationService(connection);
    
    // create new entity
    Entity e = new Entity("contact");
    e["firstname"] = "Foo";
    e["lastname"] = "Bar";
    Guid id = service.Create(e);
    
    // change just the first name and submit unchanged last name as well
    e = new Entity("contact");
    e["contactid"] = id;
    e["firstname"] = "FooChanged";
    e["lastname"] = "Bar";
    service.Update(e);
    
    // remove the entity
    service.Delete("contact", id);
    

    希望这会有所帮助。
    乔治

    【讨论】:

    • 完全正确 - 客户端代码只提交更改很重要。除了不必要的审核之外,如果您提交的字段并没有真正改变,您也可能会无意中触发自定义插件。
    猜你喜欢
    • 2012-06-17
    • 2019-01-08
    • 1970-01-01
    • 2012-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-27
    • 1970-01-01
    相关资源
    最近更新 更多