Archive for September 2011

Minimize Form Ribbon OnLoad using JavaScript

Hey Guys,

I am currently developing a CRM system in 2011 for one of our biggest clients. One of the requirements is to create editable lists which i have decided is best handled by creating holding entities for this information. For example, creating an entity to hold marketing sources allows easier reporting across selected sources and allows the marketing team to manage the list (adding new ones and deactivating unused ones). The problem with this is that to add a value to this it involves opening a whole CRM form which isn't the best. So, for these entities I don't display the left-navigation options and i wanted to minimize the Ribbon.

However, this wasn't as easy as it sounds…

First of all, having scoured the SDK i could see plenty of examples of how to add or hide BUTTONS on the ribbon and even (via other blogs) remove the ribbon itself, but nothing that would minimize the ribbon allowing it to be expanded if needed.

So after a conversation with the very helpful xRM Mike and reading another post by the excellent Rhett Clinton I used the following:

window.top.document.getElementById("minimizeribbon").fireEvent("onclick");




However, still didn't work…..



Reason being, that the Ribbon seems to be one of the last things to Load in the form, loading after the OnLoad events have fired. So, i needed to add a timeout to wait before firing the script and it worked a treat! Final code ended up as:



function toggleRibbonbar()
{
var t=setTimeout("toggleRibbon()",0);
}
function toggleRibbon()
{
window.top.document.getElementById("minimizeribbon").fireEvent("onclick");
}



Which gave the following results:



image



A big thanks to Rhett, Mike and as always the other CRM Legend that is Rob P



Ta



xRM Consultant

Saturday, 17 September 2011
Posted by XRM Consultant

At Last!! Hide Tab (Section) in CRM 2011 with Javascript!!!

Hi!

Ok, i realise that , for everyone else, this is not an earth shattering piece of JavaScript but this has been bugging me for Aaaaaaaaaaages!!!



I have been looking for the JavaScript to hide Tab (or what is now known as a section) in CRM 2011. Every other blog/SDK/forum post i read suggested the following:

   1:  Xrm.Page.ui.tabs.get(5).SetVisible(false);


   2:  Xrm.Page.ui.tabs.get(5).SetVisible(true);




No matter how i tried i could not get this to work. However, after some detective work……and reading this blog post (cheers) i realised that the bit i was missing was that in  the script, the brackets need to contain the name of the tab (name, not the Label). However, it has to be contained in “”. So my code was…



   1:  Xrm.Page.ui.tabs.get("tab_3").SetVisible(false);


   2:  Xrm.Page.ui.tabs.get("tab_3").SetVisible(true);





Sorted! Hope that helps


Cheers


xRM Consultant
Sunday, 4 September 2011
Posted by XRM Consultant

Search This Blog

Popular Post

About xRM Consultant.com

Having worked with Microsoft Dynamics CRM 4.0 in a sales & development environment, my focus now is on customising this awesome solution and showing its true potential.
Powered by Blogger.

- Copyright © xRM Consultant -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -