Multilingual Labels on Custom Buttons
Wednesday, January 30th, 2008In 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();




