
User deleted about 20k phonecall activities in CRM. Audit history is enabled on phone call and i was able to see all 20K records. How can i restore/recreate all 20k records? I tried XRMtoolbox Recycle bin but it only restores 5k records. Deleted records have both completed and open phone calls.
I tried the following code but it doesn't create completed phone call activities. Error :2 is not a valid status code for state code PhoneCallState.Open on phonecall with Id . please suggest on how i can create the completed activities using the code or any alternate methods to restore the records.
//retrieve the audit records from fetchxml
var auditrecords = service.RetrieveMultiple(new FetchExpression(fetchXML));
//loop through each audit entity record found and create deleted records
foreach (Entity audit in auditrecords.Entities)
{
// create retrieve audit detail request object
RetrieveAuditDetailsRequest auditDetailsRequest = new RetrieveAuditDetailsRequest();
//assign audit id value
auditDetailsRequest.AuditId = audit.Id;
//execute request and retrieve response
RetrieveAuditDetailsResponse auditDetailsResponse =
(RetrieveAuditDetailsResponse)_service.Execute(auditDetailsRequest);
//create auditDetail variable and assign its value
AuditDetail auditDetail = auditDetailsResponse.AuditDetail;
//type cast audtitDetail as AttributeAuditDetail
AttributeAuditDetail attributeAuditDetail = auditDetail as AttributeAuditDetail;
//create the deleted record
service.Create(attributeAuditDetail.OldValue);
} Hi,
Have you tried this free solution from Cobalt?
It allows you to restore phone calls from the audit log.
Kind regards,
Mike