I want to get a list of entities which are deleted recently. from audit summary view, we can see which entity is deleted. But how can I do it with CRM SDK(C# code)? Is it possible to write a query expression(with specified operation, date filter...) to query audit summary?
It is possible to retrieve the data change history using RetrieveRecordChangeHistoryRequest Class
This is a sample code:
// Retrieve the audit history for the account and display it.
RetrieveRecordChangeHistoryRequest changeRequest = new RetrieveRecordChangeHistoryRequest();
changeRequest.Target = new EntityReference(Account.EntityLogicalName, _newAccountId);
RetrieveRecordChangeHistoryResponse changeResponse =
(RetrieveRecordChangeHistoryResponse)_service.Execute(changeRequest);
AuditDetailCollection details = changeResponse.AuditDetailCollection;
Sample: Audit entity data changes is an example on how you can enable and disable auditing on an entity and its attributes, retrieve the data change history of the audited entity, and delete the audit records.
Related
I'm basically trying to create a primary ID between CRM and QuickBooks. Figured I'd just use the existing PK in CRM for the lookup. I'd like the PK to visible to the user, but not editable in CRM.
This has presented several problems in that you can't do that out of the box. I thought I read somewhere you could either via business rule or calculated field, but I haven't had luck with that.
It sounds like it would require web resources if I were to go this route.
The other option would be to just generate unique values for every record in Accounts and Contacts.
Does this automatically populate existing records or just new records? How do I get it to populate existing records?
You can use Auto number manager for configuring an auto-number attribute in every entity. This seeds a number based on configured format for new records. Uniqueness assured by SQL sequence feature & no need of any extra plugin/workflow.
For existing records - you can design a workflow along with a temp entity to assign auto-number. Read more.
Otherwise you can use SSIS + Kingswaysoft package to generate auto-number & assign for existing records.
I am suggesting you to create a new text field on the entity and create a pre plugin that will get the record primary GUID id from context and will set this GUID into the newly added attribute. You can set this field as read-only of form as well.
OR you can generate new GUID as well into the plugin.
Got a custom entity which has auditing enabled. Every time an user changes the stage on the Business process flow (BPF) on that entity, it's generating an audit log record with the change in the stageid which is irrelevant for the business and i cannot use the modifiedon field since the stage change is changing the modifiedon field data as well, which makes the data irrelevant for the business.
One idea would be to create a field called Business Data Modified On. Then, create a workflow that runs on change of the fields you consider to be business data and have the workflow set the new field to the current time.
It does not appear that Auditing can be disabled on the managed field StageId.
I need to write a plugin where I have to check if a particular record has any file attached.
When I remove any file from a record it gets soft deleted.
I check Annotation table in SQL server, but is there any flag that denotes the entry is soft deleted or not?
Dynamics CRM 2011 does not have a soft-delete. When the record is deleted in CRM there is a DELETE executed on the SQL server, resulting in the record being removed.
In an annotation, which is the entity for Note, an attachment is stored as bas64 encoded text. If you delete an attachment on a Note it results in an UPDATE to the annotation entity setting the fields related to the attachment to null.
If you want to trigger a plugin when an attachment is deleted you need to look at the both the delete and update events on annotation. If you want to know if the annotations related to a particular entity has an attachment you need to query annotation entity where objectid matches the entity and filename is not null.
For emails and appointments attachments are stored in activitymimeattachment instead of annotation.
How can I read from AuditBase using sdk 2015? How can I read the data in clear and understandable form?
Check out these SDK functions, Audit entity messages and methods
DeleteAuditDataRequestm Deletes all partitions containing audit data created before a given end date.
RetrieveAttributeChangeHistoryRequest, Retrieves all changes to a specific attribute.
RetrieveAuditDetailsRequest, Retrieves the full audit details of a particular audit record. The record to retrieve is specified in the AuditId property.
RetrieveRequest, Retrieves an audit record. You can also call the IOrganizationService.Retrieve method.
RetrieveMultipleRequest, Retrieves a collection of audit records. You can also call the IOrganizationService.RetrieveMultiple method.
RetrieveRecordChangeHistoryRequest, Retrieves all changes to a specific entity.
Morning-
I have an entity with auditing enabled, and would like to be able to search that entity based on whether or not a field value has been changed in the past week.
In the audit summary view in Dynamics online, it does not appear that I can achieve that. Is there any other way I can get the functionality short of coding?
You can't do this exactly, but you have a number of options to approximate this:
1) Only turn on auditing for that particular field
2) Filter for Update Event and you can filter down to that particular entity
3) Set up a workflow that runs on the update of that field only - then look for those records where that workflow is a related record