Thursday, October 19, 2006

Renaming a NavBar Item within a form through JScript

Ok, so it's be a ridiculously long time since I've posted. MSCRM 3.0 has kept us at Dynamic Methods REALLY busy. One of the good things about that is that we figure out new ways to customize MSCRM. This latest comes from one of my co-workers who took hiding a button through JScript and applied it to changing the name of a NavBar item.

On an order a client didn't want "Existing Products" to be named "Existing Products" and asked if we could rename it to say "Line Items." Well, after playing with the code for hiding a button in the toolbar this is what came out:

The code for this piece is technically not supported but obviously since it's placed in the onLoad of the form the worst thing that will happen is that the code changes in the next version and you have to update your code to what the new version uses. So, pretty low risk with great results for the user base. And whenever you make the users happy it's a big for getting them to use the system.

Anyway, this is the code that we used:

var navWriteInProducts;var navContacts;
var navExistingProducts;navWriteInProducts = document.all.navWriteInProducts;
navContacts = document.all.navContacts;
navExistingProducts = document.all.navExistingProducts;
if (navWriteInProducts != null){ = "none";
if (navContacts != null){ = "none";
if (navExistingProducts != null){
document.getElementById("navExistingProducts").innerHTML = "<img class="\" src="\" align="\" /> <nobr class="\" title="\" style="\">Line Items</nobr>"<nobr class="\" title="\">;

The key is this last piece where we replace the innerHTML. It basically replaces the default HTML and injects whatever we want to show up there. Pretty cool. Again, this code isn't new by any means, I've seen it in posts all over the MSCRM world, all we did is find a new application for the code.

Happy Coding!

David Fronk
Dynamic Methods Inc.