Hi, in D365 I'm trying to write a plugin that do somethings when I close the incident (that is when the statecode change from 0 = Active to 1 = Resolved). I read in this post [https://community.dynamics.com/365/customerservice/f/763/t/304048] that D365 no longer supports the registration of the plugin on the Close message of the incident, so I'm using SetStateDynamicEntity.
This is the configuration:
Message: SetStateDynamicEntity
Primary Entity: incident
Secondary Entity: none
Stage of Execution: PostOperation
Execution Mode: Synchronus
The code:
// . . . if (context.InputParameters.Contains("EntityMoniker")) { EntityReference incidentRef = (EntityReference)context.InputParameters["EntityMoniker"]; var incident = service.Retrieve(incidentRef.LogicalName, incidentRef.Id, new ColumnSet(true)); var state = new OptionSetValue(((OptionSetValue)context.InputParameters["State"]).Value); if (state.Value == 1) { // do somethings . . . } } // . . .
The Plugin not trigger when I close incident, but run when I reactivate the incident.
I tryed also whit trigger plugin on Create of incidentresolution...
Thank you!