Whenever there is an update in any entity on CRM , only the updated fields of that entity are passed to corresponding plugin in addition to its ID. i want to retrieve the entity with all the fields from CRM. It turns out that I can do that by using the following code
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
so when i retrieve the entity as follows
service.Retrieve(entity.LogicalName, entity.Id, cols);
it returns data type “Entity”. How can I change it to lets say contact or account.
if I use some thing like this
service.Retrieve(entity.LogicalName, entity.Id, cols).ToEntity<contact>()
…it does not recognize contact.
Any ideas??
Use the following to read data from the entity:
Entity e = service.Retrieve(entity.LogicalName, entity.Id, cols);
var x = e[‘attribute_to_read’];
You will have to type cast the data.