Multilingual Labels on Custom Buttons

Wednesday, January 30th, 2008

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
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' id='btn_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="";

//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();

Add a Button to a Form

Tuesday, January 29th, 2008

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:

//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();