Here is a nice usability feature that I really like. Currently CRM 4.0 only supports adding functional buttons via form toolbar. This suffices most of the time and mainly on strait forward data input forms. But as CRM takes giant leaps toward becoming a xRM platform, as an application architect and designer, you bow to search for more flexible ways to convey the system to the end user.
The following post presents a simple and effective way of adding an inline toolbar buttons at the section level. This is especially useful when creating complex data entry forms like designers and wizards that require multi-step / section oriented logic. It is also much more simpler to add a button to the form then going through the entire isv.config process.
Adding an inline toolbar to the form is pretty simple and involves 2 steps.
The first step is to add a new text field to the form, where you want the toolbar to appear (e.g. gi_toolbar) and hide it’s label through the form field customizations (i.e. double click on the field and uncheck display label on form checkbox).
Here is how it looks after the above step is completed:
The final step is to add the following code to the entity onload event handler and add an OnCrmPageLoad function which creates a new instance of InlineToolbar and adds the necessary buttons.
The end result looks like this:
function InlineToolbar(containerId)
{
var toolbar = this;
var container = document.all[containerId];
if (!container)
{
return alert("Toolbar Field: " + containerId + " is missing");
}
container.style.display = "none";
container = container.parentElement;
toolbar.AddButton = function(id,text,width,callback,imgSrc)
{
var btn = document.createElement("button");
var btStyle = new StyleBuilder();
btStyle.Add( "font-family" , "Arial" );
btStyle.Add( "font-size" , "12px" );
btStyle.Add( "line-height" , "16px" );
btStyle.Add( "text-align" , "center" );
btStyle.Add( "cursor" , "hand" );
btStyle.Add( "border" , "1px solid #3366CC" );
btStyle.Add( "background-color" , "#CEE7FF" );
btStyle.Add( "background-image" , "url( '/_imgs/btn_rest.gif' )" );
btStyle.Add( "background-repeat" , "repeat-x" );
btStyle.Add( "padding-left" , "5px" );
btStyle.Add( "padding-right" , "5px" );
btStyle.Add( "overflow" , "visible" );
btStyle.Add( "width" , width );
btn.style.cssText = btStyle.ToString();
btn.attachEvent("onclick",callback);
btn.id = id;
if (imgSrc)
{
var img = document.createElement("img");
img.src = imgSrc;
img.style.verticalAlign = "middle";
btn.appendChild(img);
btn.appendChild(document.createTextNode(" "));
var spn = document.createElement("span");
spn.innerText = text;
btn.appendChild(spn);
}
else
{
btn.innerText = text;
}
container.appendChild(btn);
container.appendChild(document.createTextNode(" "));
return btn;
}
toolbar.RemoveButton = function(id)
{
var btn = toolbar.GetButton(id)
if (btn)
{
btn.parentNode.removeChild(btn);
}
}
toolbar.GetButton = function(id)
{
return document.getElementById(id);
}
function StyleBuilder()
{
var cssText = new StringBuilder();
this.Add = function( key , value ){cssText.Append( key ).Append( ":" ).Append( value ).Append( ";" );}
this.ToString = function(){return cssText.ToString();}
}
function StringBuilder()
{
var parts = [];
this.Append = function( text ){parts[ parts.length ] = text;return this;}
this.Reset = function(){parts = [];}
this.ToString = function(){return parts.join( "" );}
}
}
/* Start Script Execution */
function OnCrmPageLoad()
{
window.GeneralToolbar = new InlineToolbar("gi_toolbar");
GeneralToolbar.AddButton("btnReset","Reset","15%",Reset_Click);
GeneralToolbar.AddButton("btnLookup","Lookup","10%",Lookup_Click);
//GeneralToolbar.RemoveButton("btnLookup");
GeneralToolbar.AddButton("btnAddNote","Create Note","16px",AddNote_Click,"/_imgs/ico_16_5_d.gif");
}
function Reset_Click()
{
alert('Reseting Fields...');
}
function Lookup_Click()
{
alert('lookup records...');
}
function AddNote_Click()
{
alert('Add new note');
}

19 comments:
Great Post and sample ,make it very simple and clean to implement.
Thanks,
It looks great, but I can't get it to work on the Account form. I've changed the field name to the field name on our system, but the form loads without any perceivable error, then presents the page with a blank toolbar field.
I've tried this on Preview and Published.
Any advice?
Ensure the script is enabled (checkbox in the form onload event). Put an alert(); and check it out.
If the alert works the script should work as well.
Thanks friend.Ur post really helped me to get solution to my problem.I struggled for 2 days to get the solution and finally I saw ur post.Thanks a lot
Would this be supported in future releases of CareDirector?
I don’t see why not. The DOM is changed for a specific field and the reference to this field is supported so there’s a good chance this will upgrade to the next version.
How would I add a button to your inline toolbar to launch a specific workflow for the active record shown in the form?
When "bulk edit" to bring up the same form, somehow the 3 buttons not showing up (shows a blank text box). Do I missed some step?
Thanks for the tip!!!
Sorry, but how do I do : add an OnCrmPageLoad ?
(2nd part of stap two)
Thanks in advance form Nope
For people getting a blank toolbar field, add this to the end of the script
OnCrmPageLoad();
Come and see how THOUSAND of individuals like YOU are working for a LIVING from home and are fulfilling their dreams TODAY.
CLICK HERE TO FIND OUT
"Great insight on adding inline toolbars and buttons in CRM 4.0! This guide simplifies customization and enhances user productivity. Thanks for sharing!"
Digital Marketing Course In Hyderabad
Digital Marketing Course In Ameerpet
Python training focuses on practical implementation of programming skills. It simplifies complex coding concepts. This python training enhances real-time development expertise. Learners complete hands-on assignments. File handling is included. Database connectivity is covered. Debugging techniques are explained. It prepares industry-ready professionals.
IBM Datastage course
Anibm datastage course is ideal for those who want a comprehensive understanding of ETL processes. The course content usually includes everything from basics to advanced transformations. I find the practical assignments particularly useful for applying concepts. It’s a well-rounded course that prepares learners for real-time project environments.
An iOS development bootcamp online provides intensive training for learners who want to quickly master mobile app development. It explains Swift programming, app design, and development techniques clearly. This ios development bootcamp online helps students gain practical experience through real-time projects. Learners build applications to strengthen their skills. The bootcamp prepares learners for professional iOS developer roles.
Great post! Our boomi training
helps learners master cloud integration, API management, and workflow automation with hands-on projects to prepare for real-world IT roles.
Tableau Course Online
Tableau course online is helpful for students in India. This tableau course india looks simple. Covers basics well. Good for beginners.
An ai art course helps learners understand how artificial intelligence can be used to produce digital artwork and visual content. It explains image generation models and creative AI tools clearly. This ai art course helps students gain hands-on experience through design exercises and projects. Learners create AI-generated visuals. The course prepares learners for careers in AI-powered design and media.
Salesforce Dev Training
Salesforce dev training is useful in Chennai for tech learners. This salesforce dev chennai looks simple. Easy explanation. Helpful guide.
Post a Comment