Donnerstag, 24. April 2008

Create "real" CRM 4.0-Style form-buttons in 5 minutes


There are several ways to add custom buttons onto a crm form (apart from the boring method of adding buttons via ISV-config 8-):
1. use an iFrame and an external page
Drawback: no offline availability

2.do some DOM-injection and create the buttons at runtime
Drawback: a bit tricky with placement and so on

And then there is:
3. Adis idea to transform a textattribute into a button.
The nice thing is, that you can use the normal formeditor to place it.

So I took the idea further and applied the CRM 4.0 styles to make it look 100% native and more generic to use. (it even reacts to mousedown as expected - hehe ;-)

What to do:
  1. create a textattribute (you can set searchable to "no" so the attribute doesn't show up in advanced search


  2. put it on the form
  3. make it "readonly" (Thanks Marcel!)
  4. copy the sourcecode into the onLoad event.


  5. replace the fieldname "bwt_button1" in the last line with your attributename.

  6. create your functions to tell the button what to do when clicked.


  7. have fun


source:

//////////////////////////////////////////////////////
//////////////////////////////////////////////////////

//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('bwt_button1', 'What a nice CRM 4.0 Button','184px',testfunction);

//////////////////////////////////////////////////////
/
/////////////////////////////////////////////////////

Mittwoch, 16. April 2008

This year's "CRM Jahrestagung 2008"



Also this year we could showcase one of our projects at the annual "CRM Jahrestagung" which is organized by Businesscircle and considered the most important CRM-Event in Austria. Amidst other speakers from companies such as "D. SWAROVSKI & CO", "Nestlè Nespresso", "Telefònica" and "Dresdner Bank" I could talk about our current project for BWT. Project Manager Markus Nachtmann and me focussed on the challenges of user adoption and training. We also gave our solution a name (Jeannie) to be able to blame someone, if it doesn't work as expected ;-)


PS: And yes, you can ask me how we got Jeannie into the left navigation area.