Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Suggested answer

HTML Code in InvalidPluginExecutionException Message on Connection Form

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.

  • Suggested answer
    Elie.Mouawad Profile Picture
    Elie.Mouawad 9 on at
    HTML Code in InvalidPluginExecutionException Message on Connection Form
    This way will work:
     
    throw new InvalidPluginExecutionException("Heute\u00A0war\u00A0ein\u00A0guter\u00A0Tag.");
     
  • Daniel Schneider Profile Picture
    Daniel Schneider 168 on at
    RE: HTML Code in InvalidPluginExecutionException Message on Connection Form

    Hi Bipin Kumar,

    thanks for your answer. Do I need a productiv lizenz? At the moment I use trail version for OnPremise.

    Thanks for help...

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,960 Super User on at
    RE: HTML Code in InvalidPluginExecutionException Message on Connection Form

    Hi,

    You Should log support ticket with mirosoft to check this issue.

    admin.powerplatform.com/support

    Please mark my answer verified if i were helpful

  • Daniel Schneider Profile Picture
    Daniel Schneider 168 on at
    RE: HTML Code in InvalidPluginExecutionException Message on Connection Form

    Hi all,

    I have need Information. I created an App in 9.0.2.20 CRM Version and in Contact and Connection and the message is displayed correctly. But  only in Unified Interface. Hmm now anybody an idea?

    Thanks for help...

  • Daniel Schneider Profile Picture
    Daniel Schneider 168 on at
    RE: HTML Code in InvalidPluginExecutionException Message on Connection Form

    Any ideas?

  • Daniel Schneider Profile Picture
    Daniel Schneider 168 on at
    RE: HTML Code in InvalidPluginExecutionException Message on Connection Form

    Hi Naveen,

    thanks for your Solution but it doesn´t work. See below...

    Contact Form:

    pastedimage1599977674784v1.png

    Connection Form:

    pastedimage1599977753023v2.png

    It is right that the contact and connection forms are different? Because it looks so for me. In Contact you have no WebApi Query but in Connection it is so. Thats sounds for me that we make an retrieve and the response in the InvalidPluginExecutionException is not formated. I don´t know if its right. But now i have no more ideas.

    Thanks Naveen =)

  • Naveen Ganeshe Profile Picture
    Naveen Ganeshe 3,392 Super User on at
    RE: HTML Code in InvalidPluginExecutionException Message on Connection Form

    Hi Daniel,

    can you try this one?

    try

                   {

                       var owner = entity.GetAttributeValue<EntityReference>("ownerid");

                       if (owner.LogicalName == "systemuser")

                       {

                           throw new InvalidPluginExecutionException(OperationStatus.Canceled, "yourMessage");

                       }

                   } catch(InvalidPluginExecutionException ex)

                   {

                       throw new InvalidPluginExecutionException("Heute war ein guter Tag." + ex.Message);

                   }

  • Daniel Schneider Profile Picture
    Daniel Schneider 168 on at
    RE: HTML Code in InvalidPluginExecutionException Message on Connection Form

    I don´t know if i understand you right but i use it like following:

    if(owner.LogicalName == "systemuser"){

    throw new InvalidPluginExecutionException(OperationStatus.Cancel, "yourMessage");

    }

    Can you please describe what you mean?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: HTML Code in InvalidPluginExecutionException Message on Connection Form

    There are some plugins InvaligPluginException based on some conditions to stop the Email being sent. But user should not be shown the Business process dialogue. The code seems to do exact same thing but for our situation, this is not working. Can you please give some idea on how to get saveErrorResponse and stop the Dialogue being displayed.

  • Daniel Schneider Profile Picture
    Daniel Schneider 168 on at
    RE: HTML Code in InvalidPluginExecutionException Message on Connection Form

    Hi Syed,

    thanks for your answer. Here is the result of your solution.

    Contact Form:

    pastedimage1599904554034v1.png

    Connection Form:

    pastedimage1599904631086v2.png

    Same issue =(. What I don´t know is why it is only on connections... I tried different SDK Versions from 8.0.0 to the latest in my Plugin. In CRM 8.2 OnPremise in Connection these issue is not there.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,584 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,864 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans