Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

CRM 2013. Plugin error

$
0
0

Hi

Trying to create a plugin on Post Email Create.

        protected void ExecutePostEmailCreate(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new ArgumentNullException("localContext");
            }

            IPluginExecutionContext context = localContext.PluginExecutionContext;
            IOrganizationService service = localContext.OrganizationService;

            Entity postImageEntity = (context.PostEntityImages != null && context.PostEntityImages.Contains(this.postImageAlias)) ? context.PostEntityImages[this.postImageAlias] : null;

            if (context.PostEntityImages.Contains("PostImage") && context.PostEntityImages["PostImage"] is Entity && context.Depth < 2)
            {
                try
                {
                    postImageEntity["subject"] = "MySubject";
                    service.Update(postImageEntity);
                }
                catch (FaultException ex)
                {
                     if (ex.InnerException != null && ex.InnerException is FaultException<OrganizationServiceFault>)
                {
                    var inner = ex.InnerException as FaultException<OrganizationServiceFault>;
                    if (inner.Detail.ErrorCode == -2147220891)
                        throw new InvalidPluginExecutionException(inner.Message);
                }
                    throw;

                }
            }
        }

For example it works perfect on Incident create or Task create (I've test it). But on Email create it always drop an error.

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: An unexpected error occurred.Detail: <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts"><ErrorCode>-2147220970</ErrorCode><ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" /><Message>An unexpected error occurred.</Message><Timestamp>2014-06-26T11:19:44.4680965Z</Timestamp><InnerFault i:nil="true" /><TraceText>

[CrmPackage9.Plugins1: CrmPackage9.Plugins1.PostEmailCreate]
[44c2936d-21fd-e311-80d2-0050568c1ffc: PostEmailCreate]
Entered CrmPackage9.Plugins1.PostEmailCreate.Execute(), Correlation Id: 5f7a8046-1e98-4669-9382-5311e1e44085, Initiating User: 42947473-04b0-e311-80cc-0050568c1ffc
CrmPackage9.Plugins1.PostEmailCreate is firing for Entity: email, Message: Create, Correlation Id: 5f7a8046-1e98-4669-9382-5311e1e44085, Initiating User: 42947473-04b0-e311-80cc-0050568c1ffc
Exception: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: An unexpected error occurred. (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault)., Correlation Id: 5f7a8046-1e98-4669-9382-5311e1e44085, Initiating User: 42947473-04b0-e311-80cc-0050568c1ffc
Exiting CrmPackage9.Plugins1.PostEmailCreate.Execute(), Correlation Id: 5f7a8046-1e98-4669-9382-5311e1e44085, Initiating User: 42947473-04b0-e311-80cc-0050568c1ffc

</TraceText></OrganizationServiceFault>

I've tried to search any solution on 2147220970 error but did not find any similar to me.

Any help very appreciated.


Viewing all articles
Browse latest Browse all 8223

Trending Articles



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