![]() |
#1 |
Участник
|
Danny Varghese: Plug-In When Case (Incident) Is Closed
Источник: http://varghesedanny.com/2011/02/24/...ent-is-closed/
============== Business Case: I have a client where we leveraged the case (incident) entity for a problem resolution process. The case moves through stages throughout an approval process whereby multiple people within the organization may handle the case. Once the case is resolved, the case stage needs to be set to resolved. Proposed Solution: What I needed to do here was update the stage before the case was resolved. Since resolving the case involves using the menu, there wasn’t any way to intercept the message before the case was actually resolved. I couldn’t use a workflow because I needed to make an update to the case before it was actually resolved. Since workflows run asynchronously, that wouldn’t work. I finally settled on using a plug-in, firing on the pre-event processing stage of the entity. Issue: I couldn’t figure out for the life of me what message gets sent with the plug-in execution context. Through trial and error, I finally figured out when a case is resolved, the “CLOSE” message gets sent to the context. Next, I ran into an issue where I perform a pretty standard check within my plug-in code: if ((context.InputParameters.Contains(ParameterName.Target)) && (context.InputParameters[ParameterName.Target] is DynamicEntity)) The above statement checks if the context’s input parameters contains a “target” dynamic entity. However, for a case the context sends an input parameter with the name = “IncidentResolution” and that is a dynamic entity. So the code would look like the following: if ((context.InputParameters.Contains(“IncidentResolution”)) && (context.InputParameters["IncidentResolution"] is DynamicEntity)) The last thing I did was register the plug-in as a PRE-close event, so that it gets fired before the resolution of the case gets committed to the database. I then retrieve the incident id from the incident resolution entity, and update the record’s stage value. This took me a few hours of trial and error, so hopefully this will save some time for someone, happy coding! ![]() Источник: http://varghesedanny.com/2011/02/24/...ent-is-closed/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|