Skip to main content
Suggested answer

HTML Code in InvalidPluginExecutionException Message on Connection Form

editSubscribe (0) ShareShare
ReportReport
Posted on by 168

Hi everybody,

I hope you are well. I have an Dynamics 365 9.0.18.12 and have the Problem, that the Message for InvalidPluginExecutionException contains only on the connection Form HTLM Code in the error Message.

I registered the same Plugin on the contact Form and the message is right. See below picture

pastedimage1599849101768v1.png

Error Message in Contact:

pastedimage1599849197123v2.png

Error Message in Connection:

pastedimage1599849278805v3.png

My Code:

 

if (context.InputParameters.Contains("Target") &&
                context.InputParameters["Target"] is Entity)
            {
                // Obtain the target entity from the input parameters.  
                Entity entity = (Entity)context.InputParameters["Target"];

                // Obtain the organization service reference which you will need for  
                // web service calls.  
                IOrganizationServiceFactory serviceFactory =
                    (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

                try
                {
                    var owner = entity.GetAttributeValue("ownerid");
                    if (owner.LogicalName == "systemuser")
                    {
                        throw new InvalidPluginExecutionException(OperationStatus.Canceled);
                    }
                } catch(InvalidPluginExecutionException ex)
                {
                    throw new InvalidPluginExecutionException("Heute war ein guter Tag.", ex);
                }
            }

Anybody an Idea how can i fix it?

Thanks for help.