Answered by:
CRM Dynamics 2011 - How to Manually Fire a Plugin to Update Existing Records

Question
-
My team has developed a plugin for Dynamics that fires on Create and Update of the Case (incident) entity. This plugin populates some custom fields to better meet our business needs and successfully works as intended for new cases created. However, thousands of records currently exist in the system which do not have data for the custom fields that the plugin populates. I'm having trouble figuring out an efficient way to populate the existing case records' custom fields with data generated by the plugin logic.
Is there a way to manually fire the plugin by calling the update event (without changing anything on the case record except for the change the plugin will make)?? Or is there some other suggestion or solution for utilizing the plugin logic to update the existing case records (web resource? javascript? database update?)?
Any and all suggestions and help will be appreciated.Friday, July 22, 2011 7:15 PM
Answers
-
I have found a work around for this in my experience.
1. Create a custom trigger entity (just a simple custom entity)
2. Create a ribbon button with jscript behind it to create or update an instance of that trigger entity.
3 Attach the plugin to the update or create message of the trigger entity.
To get an idea of how to create or update an entity instance from jscript look at these:
http://mileyja.blogspot.com/2011/04/create-requests-in-net-and-jscript-in.html
http://mileyja.blogspot.com/2011/04/how-to-use-update-requests-in-net-and.html
Jamie Miley
Check out my about.me profile!
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!- Proposed as answer by Jamie MileyModerator Friday, July 22, 2011 7:33 PM
- Marked as answer by Jim Glass Jr Sunday, July 24, 2011 7:44 PM
Friday, July 22, 2011 7:33 PMModerator
All replies
-
Unlike CRM workflow, Plugin cannot be run on-demand.
If you have the plugin code, it should be fairly simple to write a console app to loop through all existing records and make the update.
Daniel Cai | http://danielcai.blogspot.comFriday, July 22, 2011 7:29 PM -
I do have the plugin code. However, I'm not familiar with console apps... could you explain in a little more detail please?
Friday, July 22, 2011 7:32 PM -
I have found a work around for this in my experience.
1. Create a custom trigger entity (just a simple custom entity)
2. Create a ribbon button with jscript behind it to create or update an instance of that trigger entity.
3 Attach the plugin to the update or create message of the trigger entity.
To get an idea of how to create or update an entity instance from jscript look at these:
http://mileyja.blogspot.com/2011/04/create-requests-in-net-and-jscript-in.html
http://mileyja.blogspot.com/2011/04/how-to-use-update-requests-in-net-and.html
Jamie Miley
Check out my about.me profile!
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!- Proposed as answer by Jamie MileyModerator Friday, July 22, 2011 7:33 PM
- Marked as answer by Jim Glass Jr Sunday, July 24, 2011 7:44 PM
Friday, July 22, 2011 7:33 PMModerator