Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Suggested answer

incident reactivate event

Posted on by 50

Good Day

We have a requirement from Customer Experience, why a Case is ReActivated. They are asking for a drop down optionset and it should apprear only once a case is Re-Activated.

I tried Nishant Rana Blog, which creates a plugin and it is supposed to be activated once a Case is Re-Open/Re-Acticated.

Nishant Rana Code is not working for me, It is even running when a case status is Changed(New->In Progress). 

My plugin Code below:

if (context.InputParameters.Contains("EntityMoniker"))

           {

               var targetEntity = (EntityReference)context.InputParameters["EntityMoniker"];

               if (targetEntity.LogicalName == "incident")

               {

                   Entity incident = new Entity("incident");

                   incident.Id = context.PrimaryEntityId;

 

                   QueryExpression query = new QueryExpression("incident");

                   query.ColumnSet = new ColumnSet("col1""reopenflag");

 

                   query.Criteria.Conditions.Add(new ConditionExpression("incidentid", ConditionOperator.Equal, incident.Id));

                   var result = service.RetrieveMultiple(query);

                   foreach (var entity in result.Entities)

                   {

                       // Get the Columns from the Entity Obj Like this. Depands on type of the Column.

                       _valueDate = entity.Contains("field1") && entity["field1"] != null ? entity["field1"]).Value : DateTime.MinValue;

                   }

 

                  

 

                   int state = ((OptionSetValue)context.InputParameters["State"]).Value;

 

                   if (state==0)

                   {

                       incident.Attributes["flag"] = true;

             

                           incident.Attributes["field1"] = GetValidLocalDate(DateTime.Now);

             

                       

                       incident.Attributes["pluginmessage"] = Convert.ToString(context.MessageName);

                       service.Update(incident);

                   }

 

 

               }

           }

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,962 Moderator on at
    RE: incident reactivate event

    Hi,

    You should check Case previous status. And if pervious status is Resolved or Cancelled then only you should execute your code.

    Two thing you will have to check in your plugin -- Case previous status and Case status value which is coming in Context.

    When you check previous status and when case status is changed from New-->Inprogress your code will not get executed as previous status is not resolved or cancelled instead it is new.

    Please mark my answer verified if i were helpful

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans