Monday, February 6, 2012

disable field and hide/unhide field, section and form

disable field


    crmForm.all.new_link.disabled = false;  //disable the field
    crmForm.all.new_link.disabled = true;   //enable the field

hide/unhide field


    crmForm.all.<fieldname>_c.style.display = "none";
    crmForm.all.<fieldname>_d.style.display = "none";

hide/unhide section



    crmForm.all.<fieldname>.parentElement.parentElement.parentElement.style.display="none";

   another way :


    document.getElementById("tab<tabNo>").childNodes[0].rows[<sectionNo>].style.display = "none";
    // <tabNo> is zero based tab number from left. <sectionNo> is zero based section number from top.


hide/unhide tab


   document.getElementById("tab<tabNo>Tab").style.display = "none";
   // <tabNo> zero based tab number from left




Wednesday, February 1, 2012

Button in CRM


it is very easy to create button in CRM.

just follow the step.

1. create one text attribute.
2. named new_link.
3. put the below code in OnLoad vent of the form.




//CRM 4.0-Style button creator
//Creates a Button from a Textattribute.
//For every Button you need, create a nText Attribute and place it on the Form
//mario raunig, world-direct 04/2008

function create_button_from_textattribute(fieldname, buttontext, buttonwidth,clickevent)
{
functiontocall=clickevent;
crmForm.all[fieldname].DataValue = buttontext;
crmForm.all[fieldname].style.borderRight="#3366cc 1px solid";
crmForm.all[fieldname].style.paddingRight="5px";
crmForm.all[fieldname].style.borderTop="#3366cc 1px solid";
crmForm.all[fieldname].style.paddingLeft="5px";
crmForm.all[fieldname].style.fontSize="11px";
crmForm.all[fieldname].style.backgroundImage="url(/_imgs/btn_rest.gif)";
crmForm.all[fieldname].style.borderLeft="#3366cc 1px solid";
crmForm.all[fieldname].style.width=buttonwidth;
crmForm.all[fieldname].style.cursor="pointer";
crmForm.all[fieldname].style.lineHeight="18px";
crmForm.all[fieldname].style.borderBottom="#3366cc 1px solid";
crmForm.all[fieldname].style.backgroundRepeat="repeat-x";
crmForm.all[fieldname].style.fontFamily="Tahoma";
crmForm.all[fieldname].style.height="20px";
crmForm.all[fieldname].style.backgroundColor="#cee7ff";
crmForm.all[fieldname].style.textAlign="center";
crmForm.all[fieldname].style.overflow="hidden";
crmForm.all[fieldname].attachEvent("onmousedown",push_button);
crmForm.all[fieldname].attachEvent("onmouseup",release_button);
crmForm.all[fieldname].attachEvent("onclick",functiontocall);
}

function push_button(){
window.event.srcElement.style.marginLeft="1px";
window.event.srcElement.style.marginTop="1px";
}

function release_button(){
window.event.srcElement.style.marginLeft="0px";
window.event.srcElement.style.marginTop="0px";
}

// tell the button what to do
function testfunction()
{
alert('Ta-da!');
}

// create the button
create_button_from_textattribute('new_link', 'new resource','84px',testfunction);

enjoy it