Archive

Posts Tagged ‘hide’

CRM4: Hiding tabs and sections

June 17th, 2009

Hello all,

I am currently working on a small CRM project and one of the requirements was to hide a section and a tab onLoad.

// Hiding the Contract section

crmForm.all.contractid_c.parentElement.parentElement.style.display=’none’;

// Hide the KB article tab (2nd Tab)

crmForm.all.tab1Tab.style.display=’none’;

I’m sure you can use this in other ways (i.e:. onChange, onClick etc..).

Happy Coding!

MSCRM-Admin CRM 4.0, Customizations, JavaScript , , , , ,

Add a Button to a Form

May 23rd, 2009

This post is to show how to add a Button to a MS CRM Form, not to the Navigation Pane nor to the Menu Bar, but to the actual Form itself.
In this post I will show a simple usage of the Button, to show its function. You can understand that more advanced functions can be triggered by the button, but that’s not the aim of this post.For this example I have used the default Contact Form. The Address Section is hidden onLoad and a Button is shown.

Button on Form

By Clicking on the Button the Section with the Address Details is shown again. In this example the Button Disappears, because it has no use anymore. (I could have added a function to hide the section again).

Button on Form2

To achieve the above I have created a new Section with a new Attribute (new_button).

Button on Form3

Next to that I placed the following Script in the onLoad of the Form:

Update: 9th March 2010 - updated code blocks - wordpress broke the code!

// Start of onLoad Code

//to hide the address details onload
crmForm.all.address1_name_c.parentElement.parentElement.parentElement.style.display = 'none';

// Replace the attribute new_button with the button and create a link to the onclick function
function CreateButton() {
var fieldTable = crmForm.all.new_button_d;
var html = "<table border='0' cellspacing='0' cellpadding='0'><tr><td width='0px'>" + fieldTable.innerHTML + "</td><td width='200px'><input type='button' value='Show Address Details' onclick='Button_OnClick()' style='background-color:#d8e8ff' style ='border-width:2px'/></td></tr></table>";
fieldTable.innerHTML = html;
//hide the new_button attribute
document.all.new_button.style.display='none';
crmForm.all.new_button_c.innerText="";
}
// Function to be triggered onClick
Button_OnClick = function() {
//to show the address details
crmForm.all.address1_name_c.parentElement.parentElement.parentElement.style.display ='block';
//In this case I hide the button, because I haven't added the button has not function anymore in this case
crmForm.all.new_button_c.parentElement.parentElement.parentElement.style.display ='none';
}
// Initialization: Execute the selected sample
CreateButton();

MSCRM-Admin CRM 4.0, Customizations, JavaScript , , , , ,

Hiding Sidebar Navigation (Related Entities)

September 18th, 2008

Hi Guys,

Recently for a client, we had to create some many-to-1 relationship from Contact to Accounts & Opportunities.  We then had the problem of the related entity navigation on the side showing up.  They didn’t want to see all these related navigations. I added some onLoad code on the contact form to hide the Sidebar navigation.

Before:

The key is to get the relationship Elementid from the source code of the page (Press Ctrl + N to open new window, then click on the ‘view’ menu and click ’source’). Then find the Name of the Navigation and find the element id:

onLoad code:
document.getElementById("nav_new_contact_account_dm1").style.display = "none";
document.getElementById("nav_new_contact_account_dm2").style.display = "none";
document.getElementById("nav_new_contact_account_dm3").style.display = "none";
document.getElementById("nav_new_contact_account_dm4").style.display = "none";
document.getElementById("nav_new_contact_opportunity_dm1").style.display = "none";
document.getElementById("nav_new_contact_opportunity_dm2").style.display = "none";
document.getElementById("nav_new_contact_opportunity_dm3").style.display = "none";
document.getElementById("nav_new_contact_opportunity_dm4").style.display = "none";

After:

I hope this helps you all and gives you some idea of how powerful JavaScript & CRM are.

-MSCRM Person

MSCRM-Admin CRM 4.0, Customizations, JavaScript , , , , , ,