开发者

MS CRM 2011: Auditing feature and Updates via IOrganizationService webservice

开发者 https://www.devze.com 2023-02-17 12:21 出处:网络
we are planning to use the auditing feature of CRM 2011 to track who has changed which infield for a couple of entities.

we are planning to use the auditing feature of CRM 2011 to track who has changed which infield for a couple of entities. But what happens if you update an entity via the IOrganizationService?

For example let's say you have an addres entity in your system with City="London" and Street="Baker Street". Now in your Code you create an entity object (late bound) for this address. You set its GUID, City="London" but Street="Downing Street"! Now you call IOrganizationService.Update for this entity. Will the auditing feature be aware of that the Street has changed but the City has not? Or will he tell me that the the City was changed wh开发者_开发问答en in fact it wasn't?


the audit will pick up unchanged fields that were submitted as part of the Update message. For example, the following code will result in the audit record recording the change to the lastname attribute though submitted value is identical to the value in the database. In other word, auditing is performed on the message level and without actually comparing values with the database (which, as I understand, would be quite expensive exercise).

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);

Hope this helps.
George

0

精彩评论

暂无评论...
验证码 换一张
取 消