Document integration – part 3: Tinkering with the ribbon

I’ve been a bit quiet lately. This is caused by the problem I’m tackling at this moment. In this article I’ll explain what I’m working on, and more important what details I need to smooth out before I can go into full speed.

In my previous article –  Hardcore CRM: Dynamic plug-in step (de) provisioning –  I showed a rough sketch in which I showed how the document integration solution should look like.

Concept

The idea behind the sketch is as follows: 

  • Within the solution there is a settings entity. In this settings entity you can define which entities should support document integration (with the option to disable the document integration for a given entity).
  • At the moment you enable document integration on an entity, the ribbon for that entity (form ribbon) is modified dynamically. A new button will be added (see yellow button above).
  • Once you click the yellow button, a new form appears in which the entity name and the entity id is known. In that form a list of related documents is shown.  In case you click a document hyperlink, the document is streamed to your browser. The default action on your browser determines what to do with the document.
  • The form also provides an option to upload a new document to the document management system. That document will be related to the entity automatically.

The communication between the form and CRM is done by implementing a custom action.

The behaviour of the custom action is controlled by its input parameters. The output parameters of the action are read by the form logic and result in further actions (e.g. show a list of documents,  load a single document).
We can implement the custom action to support multiple storage methods (e.g. SharePoint, DropBox, OneDrive, Google Drive, WebService etc).

The custom action itself is not the problem. * yeah right, what is taking so long? *

The hardest part in this solution is the dynamic provisioning of the ribbon because I want to be able to add and remove ribbon buttons on the fly. This task is doable but I want to implement it with as less overhead as possible.

In the sketch below, I drew how the process looks like

Process

We start with an entity ribbon.

We make an export of it and the result is an in memory zipped byte array.  After we extracted the zipped byte array we end up with a string containing the entity ribbon xml.
Once we have the xml string, we can write some code to inject the button and to attach the script we need to pop up our custom form. This process is quite clear to me.

Then there is the difficult part. We have to zip the modified xml and publish it back to the ribbon. In the end the result should be a modified ribbon with an additional button.

At the moment I’m figuring it out on how to do this. How I should make the PublishXmlRequest.

On codeplex there is a great project which I use for inspiration, this is the “Ribbon Editor for Dynamics CRM 2011” and contains all logic I need.
I know for sure that this problem will be solved, it only will cost me some additional time.

If any of you have suggestions, ideas and/or tips regarding ribbon xml publishing… please feel free to share it with me.

2 thoughts on “Document integration – part 3: Tinkering with the ribbon

  1. Tanguy says:

    Thanks for mentioning the project I wrote long time ago to edit ribbon

    • Hi Tanguy,

      thanks for writing the code in the first place. It provided me with a lot of useful insights. I combined your piece with a MSDN sample and then I was able to crack the nut.

      Bas

Leave a Reply

Your email address will not be published. Required fields are marked *