2

Using the crm 2011 sdk samples I've written a C# routine in Visual Studio to deactivate all active records in a custom entity. Now I'd like to wire this routine to a custom button on ribbon (figured that one out using RibbonDiffXml) However I'm unsure how to go about deploying. Am I creating a dll to register with the plugin registration tool? Any guidance would be appreciated!

maatthias
  • 137
  • 2
  • 12

2 Answers2

3

As I see it, you have two options:

  1. Rewrite your code to use the Organization Service from JavaScript. You can put the code completely inside the button this way. However, this requires manually constructing the SOAP calls to the API. The SDK has a walkthrough for this.
  2. Include your code in a plugin, create a custom entity that you can register this plugin against, and create an instance of that entity from the JavaScript that will fire when clicking your ribbon button. This is detailed in an answer to a similar question.
Community
  • 1
  • 1
Matt
  • 4,656
  • 1
  • 22
  • 32
  • Thanks Matt. I will investigate the javascript rewrite. – maatthias Nov 22 '11 at 19:29
  • +1. Additionally, for option 2, the linked question also includes an answer by @saeid that involves registering a plugin against the *update* of the parent entity, rather than the *create* of a custom entity. This may or may not be more easily managed than the creation and maintenance of an artificial entity. – Peter Majeed Nov 22 '11 at 19:44
  • OK so far I was able to use the soaplogger in the SDK to run my c# routine to deactivate records and get the raw soap requests. Problem here is that now I have 5 soap requests (1 for each record). And what I really need is javascript that will deactivate all active records. Any idea on how to tweak the request to do this? Thanks! – maatthias Nov 22 '11 at 20:58
  • @maatthias You can use a SOAP request to retrieve multiple IDS (all the IDs) in a particular entity, then send one SOAP request per ID to delete each record, but there's no way in the entire API that I've ever heard of to handle a set based deletion. Even the bulk delete feature deletes records one at a time. – Peter Majeed Nov 23 '11 at 16:39
1

Here are even more alternative solutions:

  • Create a workflow plugin and trigger that workflow (that runs async in the background). Triggered manually, on an event or from a javascript.

  • Create a javascript but use the REST API or even better, use the CrmRestKit to deal with the REST-part and keep your scripts clean and easy to read and maintain.

  • Create an ASP.NET page (or silverlight control) that displays a dialog that shows a progress bar while the process is running.

Christian V
  • 2,010
  • 17
  • 26