Posted on October 6th, 2010 – by Huib Aarts
If you disable a Business Required field, it is no longer Business Required. So the field can be empty if you save the Form. An easy way to solve this is to manually check the Required condition on the onSave of the form.
If the field is empty the onSave is stopped.
if (crmForm.all.new_requiredfield.DataValue == null)
{
alert ("Please fill the required field");
event.returnValue = false;
return false;
}
Posted on October 6th, 2010 – by Huib Aarts
In addition to the last post and a new Feature of MS CRM 4.0, I have improved my script to create a Button on a MS CRM Form with a Multilingual Extension. I will show the same script as in the last post, see Screens over there, but with the Multilingual possibilities:
//to hide the address details onload
crmForm.all.address1_name_c.parentElement.parentElement.parentElement.style.display ='none';
//USER_LANGUAGE_CODE: Provides an LCID value representing the Microsoft Dynamics CRM Language Pack that the user has chosen
var Lang = USER_LANGUAGE_CODE
//if language is English
if (Lang == "1033")
{
var BtnTxt = "Show Address Details"
}
//if language is Dutch
if (Lang == "1043")
{
var BtnTxt = "Bekijk Adres Details"
}
//if language is French
if (Lang == "1036")
{
var BtnTxt = "Affiche les details de l'adresse"
}
// Replace the attribute new_button with the button and create a link to the onclick function
CreateButton =function()
{
var fieldTable = crmForm.all.new_button_d;
var html = "
";
fieldTable.innerHTML = html;
//hide the new_button attribute
document.all.new_button.style.display='none';
crmForm.all.new_button_c.innerText="";
//change the label of the button dependend on the language
var objBtn = document.getElementById('btn_details');
objBtn.value = BtnTxt;
objBtn.title = BtnTxt;
}
// 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();
Posted on October 6th, 2010 – by Huib Aarts
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.

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).

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

Next to that I placed the following Script in the onLoad of the Form:
//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
CreateButton = function() {
var fieldTable = crmForm.all.new_button_d;
var html = "
";
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();