Wednesday, July 20, 2011

How to write Javascript on event of ribbon buttons ms cmr 2011

its very required things to write some JS code in the buttons of ribbon in ms crm 2011.
very simple to do so.
1. export your entity(with ISV if u hv migrated from 4.0)
2. find the control you are looking for and get the ID, suppose its Mscrm.Isv.new_netityname.Form.Group1.Control0
3. then go to CommandDefinitions section and add a CommandDefinition with the rule and actionas follows
<CommandDefinition Id="Mscrm.Isv.new_entityname.Form.Group1.Control0">
<EnableRules />
<DisplayRules>
<DisplayRule Id="Mscrm.Isv.new_entityname.Form.Group1.Control0" />
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName="Mscrm_Isv_new_entityname_Form_Group1_Control0_2" Library="$Webresource:new_entityname_ribbon.js" />
</Actions>
</CommandDefinition>
4. Now in the webresources you can get the file new_entityname_ribbon.js and create a function Mscrm_Isv_new_entityname_Form_Group1_Control0_2, then you can write your logic and can call other functions from ouside JS file.

hope this will help.
you can find the solutions form MS site also MS ribbon

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Sorry for the previous post, the tags got thrown out when I posted.

    Just a friendly note, in the JavaScriptFunction tag, it should be noted that the $Webresource: token should be *all lowercased* as it is case sensitive last I checked. Therefore it should be $webresource:new_entityname_ribbon.js as the Library path.

    ReplyDelete