Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Plug-in log outside transaction

$
0
0

Hi,

I have plug-in and in case of exception, I want to log error & throw exception to user. 

Below is my code:

plug methd
try{ // business logic } catch(exception ex) { OrgService.LogError(ex); } public string LogError(this IOrganizationService service, Exception ex) { var result = string.Empty; try { //set log exception request OrganizationRequest logExceptionRequest = new OrganizationRequest("new_error"); logExceptionRequest["StackTrace"] = ex.Message; ExecuteMultipleRequest executeMultipleRequest = new ExecuteMultipleRequest() { Requests = new OrganizationRequestCollection(), Settings = new ExecuteMultipleSettings() { ContinueOnError = true, ReturnResponses = true } }; executeMultipleRequest.Requests.Add(logExceptionRequest); ExecuteMultipleResponse resp = (ExecuteMultipleResponse)service.Execute(executeMultipleRequest); foreach (var responseItem in resp.Responses) { if (responseItem.Response != null) { OrganizationResponse response = (OrganizationResponse)responseItem.Response; result = (string)response["Token"]; } else if (responseItem.Fault != null) { result = responseItem.Fault.Message; } } } catch (FaultException<OrganizationServiceFault> fault) { result = fault.Message; } return result; }


Error received from LogError Method - "Request not supported: new_error"

Any suggestion outside transaction to log error on entity.


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>