Skip to main content

Notifications

Customer Service forum

Plugin not triggered when closing a case

Posted on by 40

We have two plugins that are registered on the Close-message of a case (incident). But they don't get triggered when you resolve a case.

From what I can see in the documentation the Close-message is still a supported type of message on the incident-entity?

The plugins are working in our 8.2 environments, this issue has only occurred in our newly updated sandbox environment that runs version 1710 (9.1.0.876).

Have this changed since version 8.2 or is something wrong with our environment?

Categories:
  • Verified answer
    Felix A Profile Picture
    Felix A 40 on at
    RE: Plugin not triggered when closing a case

    UPDATE: I got a response from Microsoft today, it turns out that we can no longer register plugins to trigger on the Close-message of a case, this is by design. Unfortunately the documentation has not been updated and it will probably take some time until it is. The workaround is to either register the plugin against the Create-message of Incident Resolution or an Update on the case status.  

  • Felix A Profile Picture
    Felix A 40 on at
    RE: Plugin not triggered when closing a case

    Thank you everyone for looking into this, I have report this to Microsoft now and waiting for a response. As a workaround we solved it by looking at the Create of an incidentresolution instead.

    Best regards, Felix

  • Verified answer
    a33ik Profile Picture
    a33ik 84,321 Most Valuable Professional on at
    RE: Plugin not triggered when closing a case

    Hello,

    I took a look on my latest instance and you're absolutely correct - Close message doesn't trigger the plugin anymore. That looks like a bug for me so I encourage you to get in touch with Microsoft and open a support ticket.

    In the meantime you can use following workaround I found:

    1. Change plugin to handle SetStateDynamicEntity message.

    2. To differentiate different changes of incident check for parent context and specifically message "ResolveIncident" like in screenshot of context:

    CaseResolve.png

    3. Change your code for this scenario.

    Good luck.

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Plugin not triggered when closing a case

    Hi,

    I tried this with a sample plugin on close request and observed the same behaviour i.e. plugin didn't trigger. As there is no info on deprecation, I think its a bug in the current version.

    I would suggest to contact Microsoft Support to get this confirmed- https://admin.dynamics.com

    Hope this helps.

  • Felix A Profile Picture
    Felix A 40 on at
    RE: Plugin not triggered when closing a case

    Absolutely, it's not all but the point is that check if the message is "close" and then throw an exception right away, but this never happens:

    public void Execute(IServiceProvider serviceProvider)

           {

               try

               {

                   var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

                   var factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

                   var service = factory.CreateOrganizationService(context.UserId);

                  // FOR DEBUGGING PURPOSES

                   if(context.MessageName == "Close") {

                      throw new InvalidPluginExecutionException("MessageName == Close");

                   }

                   if (context.MessageName == "Close" && context.InputParameters["IncidentResolution"] != null)

                   {

                       var caseResolution = (Entity)context.InputParameters["Target"];

                       var caseEntity = service.Retrieve("incident",

                           ((EntityReference)caseResolution.Attributes["incidentid"]).Id,

                           new ColumnSet("stq_solutiondescription", "stq_sendclosecaseemailtocustomer", "parentcaseid", "customerid", "stq_resolvechildcases", "stq_resolverelatedcases_noemail", "ownerid", "statecode", "statuscode"));

                       var status = caseEntity.Attributes.Contains("statuscode") ? (OptionSetValue)caseEntity["statuscode"] : new OptionSetValue(2);

                       if (CaseIsValidForUpdate(caseEntity, service))

                           ResolveValidChildCases(caseEntity, caseResolution, service, status);

                   }

               }

               catch (Exception e)

               {

                   throw new InvalidPluginExecutionException("ResolveChildCases: " + e.Message + "\r\nStacktrace: " + e.StackTrace);

               }

           }

  • Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Plugin not triggered when closing a case

    Hi,

    can you share your code?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,902 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,297 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans