Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

incident reactivate event

$
0
0

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);

                   }

 

 

               }

           }


Viewing all articles
Browse latest Browse all 46379

Trending Articles



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