Answered by:
Plugin Trigger on multiple edit of Cases?

Question
-
Hi,
I have a plugin that gets triggered when a Case is created or updated. However, I just realized that the plugin doesn't seem to be triggered when I have multiple cases selected and doing an update. Is this normal behaviour? Any way to get around this?
Thanks.
Thursday, July 29, 2010 7:18 PM
Answers
-
If your plugin is registered to the Parent pipeline of the Update message, it will not be triggered by a multiple-edit. It will need to be registered to the Child pipeline instead.
Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.com- Marked as answer by SL. _ Friday, August 13, 2010 8:07 PM
Friday, July 30, 2010 6:34 PMModerator
All replies
-
If your plugin is registered to the Parent pipeline of the Update message, it will not be triggered by a multiple-edit. It will need to be registered to the Child pipeline instead.
Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.com- Marked as answer by SL. _ Friday, August 13, 2010 8:07 PM
Friday, July 30, 2010 6:34 PMModerator -
Thanks David, I will give this a try. Are there any major differences between registering a plugin to the Parent pipeline as opposed to the Child pipeline?Friday, July 30, 2010 8:11 PM
-
Yes. You cannot use IPluginExecutionContext.CreateCrmService or (by direct correlation) use ICrmService instances to make calls back to the web services. You will need to instantiate your own CrmService objects. Read more here: http://msdn.microsoft.com/en-us/library/cc151083.aspx
Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.comFriday, July 30, 2010 9:32 PMModerator -
I have tried to deploy the plug-in for the Child Pipeline, however when I tried to edit multiple cases, CRM returns an error telling me that the records were not saved because of an error. Is there a particular way the plug-in needs to be registered or deployed?Tuesday, August 3, 2010 9:46 PM
-
You'll probably want to enable tracing , and scan the logs . There are some operations which cannot be performed in a synchronous, child-pipeline Plug-in: notably Retrieve and RetrieveMultiple. The only operations you can perform are Create, Update, and Delete.
Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.comTuesday, August 3, 2010 11:13 PMModerator -
That could be a problem for my plugin as I need to use the retrieve operation. I ran the trace for the plugin and it does seem like the Retrieve request is failing. What I am doing is on a case update, since most of the time not all fields would be modified, I would use take the incidentid from an image I have setup Post Stage and do a retrieve on the record in CRM that was just updated, and extract all of the necessary fields from that retrieval.
Would there be another way to pull the data from the fields in a Case after an update, without using the retrieve operation?
Wednesday, August 4, 2010 6:12 PM -
So basic question you should ask yourself is whether you really want all of this in synchronous pipeline or could it be also achieved by doing an asysnchronous implementation. For example you could set a flag (custom attribute) in all of these bulk updated case, using the plugin in childpipeline. After that in a crm workflow which is triggered on update of this flag on a case instance, you can implement your custom implementation in a workflow sequence activity. But it all really depends if your requirement can be still possibly met with asynchronous implementation.
- Proposed as answer by ameed sheikh Wednesday, August 4, 2010 7:01 PM
Wednesday, August 4, 2010 7:01 PM -
Absolutely! Look into Entity Images . They're designed to function as snapshots of the record submitted to the operation, either before the operation ("pre image") or after the operation ("post image"). When you register your Plug-in, you can configure the image you desire. For your needs, you'll want a Post Image. Additional reading here:
http://community.dynamics.com/blogs/crminogic/comments/67943.aspx
http://crm.davidyack.com/journal/2007/10/14/using-prepost-images-in-plug-ins.html
Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.comWednesday, August 4, 2010 7:03 PMModerator -
Hi David,
Thank you for your help with the suggestions so far. I am running into an issue at this point, and that is the plug-in works in two of the three CRM environments that I am working with, but the actual production instance is not working. I tried to run a trace when triggering the plug-in, but when I looked at the trace logs though, the plug-in didn't generate any error message.
Is there a particular setting on the server that needs to be in place before a plug-in would work in the Child Pipeline?
Thanks!
Wednesday, August 11, 2010 7:06 PM -
All you should have to do is register your Plugin on the server, as you have in your development environments. You should carefully note, however, if you have used the WSDL instead of the SDK DLLs, you may need to point the Web References to the production server and compile your code for that environment before registering it. Other than that, you'll really need to examine the differences between the environments to determine the fault. Also, if you have a "try-catch" block that is discarding exceptions, you will probably not encounter errors in the trace logs. You may want to remove or improve those blocks.
Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.comWednesday, August 11, 2010 7:57 PMModerator -
Strangely enough, I was tweaking the registration settings and it appears that running the plug-in on Async mode actually worked for me on production. However, I found that the plug-in either executes relatively quickly (within a few seconds to a minute), or it will not fire at all. Would registering the plug-in with the Child Pipeline have anything to do with this random behaviour?
Wednesday, August 11, 2010 8:52 PM -
It shouldn't be random. Is the Bulk Update process not triggering your Plug-in for some selected records? Have you made sure to restart IIS and/or the Async processing service after registering the plug-in?
Dave Berry - MVP Dynamics CRM - http:\\crmentropy.blogspot.comWednesday, August 11, 2010 11:24 PMModerator -
Thank you David for all your help. I was able to get this running in Sychronous mode across all servers. I realized that I have not done an IIS reset as well as the reset of the Asychronous service. After resetting both items the plug-in worked as expected.Friday, August 13, 2010 8:05 PM