locked
RetrieveAuditDetailsRequest Account does not exist RRS feed

  • Question

  • I created the following code to restore some accounts that were mistakenly deleted. Everything had been working fine during my early testing, but now I receive this error for every account I'm trying to restore:

    Unhandled Exception: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Account With Id = c011f583-8741-e211-bce3-78e7d1622fbb Does Not Exist

    Server stack trace:

      at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)

      at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

      at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCall

    Message methodCall, ProxyOperationRuntime operation)

      at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]:

      at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

      at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

      at Microsoft.Xrm.Sdk.IOrganizationService.Create(Entity entity)

      at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.CreateCore(Entity entity)

      at OrganizationRestoration.Program.Main(String[] args)

    This is the code:

    while (rdr.Read())

                   {

                       if (!rdr.IsDBNull(0))

                       {

                           auditId = new Guid(rdr["AuditId"].ToString());

                           RetrieveAuditDetailsRequest request = new RetrieveAuditDetailsRequest();

                           request.AuditId = auditId;

                           RetrieveAuditDetailsResponse response = (RetrieveAuditDetailsResponse)service.Execute(request);

                           AuditDetail auditDetail = response.AuditDetail;

                           var attributeAuditDetail = auditDetail as AttributeAuditDetail;

                           //create the deleted record

                           if (attributeAuditDetail != null)

                               service.Create(attributeAuditDetail.OldValue);

                       }

                   }

    I'm not sure what change I may have made that would cause this to stop working. Ideas?

    Thursday, May 8, 2014 6:23 PM