6/25/2012 UPDATE: This new version will work in either Header, Footer, Body or all!
In the post we are going to take a look at licking a problem that I have with Microsoft Dynamics CRM 2011. That is adding buttons to a form to perform some sort of action. There are several ways of firing script such as onchange of fields or even adding buttons to the ribbon bar. The ribbon bar is pretty interesting way of adding functionality, if you have the time download the definitions, find the exact spot and order you want your button, then finally re-import it. Its a cool feature and these new buttons are available for all forms for the entity, but it is overkill for simple things. This post will show you how to quickly add buttons to a page with just a few lines of javascript.
In the post we are going to take a look at licking a problem that I have with Microsoft Dynamics CRM 2011. That is adding buttons to a form to perform some sort of action. There are several ways of firing script such as onchange of fields or even adding buttons to the ribbon bar. The ribbon bar is pretty interesting way of adding functionality, if you have the time download the definitions, find the exact spot and order you want your button, then finally re-import it. Its a cool feature and these new buttons are available for all forms for the entity, but it is overkill for simple things. This post will show you how to quickly add buttons to a page with just a few lines of javascript.
- This plugin requires Jquery, download the latest version and add it along with the CRMButtonBar plugin to the script collection for your form.
- Create a new attribute (a text field is fine) and add the new attribute to the form where you want the buttons to show up.
- Either add the following code to your main Javascript page or or create a new script page.
1 $(document).ready(function(){
2 $('#new_newname_d').CrmButtonBar ({
3 sourcefield: 'new_newname',
4 buttons:[
5 {
6 text : "Press Me",
7 click: function (){alert("Button 1 Pressed");},
8 width : '50px'
9 },
10 {
11 text : "Press Me Too!",
12 click: function (){alert("Button 2 Pressed");},
13 width : '150px'
14 }]
15 });
16 });
When you’re done, your page should look similar like the following: