Hello,
Though its an age old topic, would like to write down step-by-step approach to add an ribbon button for reference.
Prerequisite:
CRM instance with ribbon workbench solution or Xrmtoolbox
Scenario:
Add a ribbon button on account and on click of the ribbon button show the URL of the record.
Steps:
Though its an age old topic, would like to write down step-by-step approach to add an ribbon button for reference.
Prerequisite:
CRM instance with ribbon workbench solution or Xrmtoolbox
Scenario:
Add a ribbon button on account and on click of the ribbon button show the URL of the record.
Steps:
- Open ribbon workbench
- Select the solution that contains account entity.
- Add a new js command. Using command we can define JavaScript function or an URL action called on click of ribbon button.
- Lets add a Javascript action and call our Alert function which is available in existing Js webresource
- Now add the ribbon button and fill in the necessary details. Also link the command to the button and publish the changes
- Once done navigate to account and click the button to view the alert
Code snippet to alert URL:
function alertURL() {
var url= "{0}/main.aspx?etn={1}&id={2}&pagetype=entityrecord"
Xrm.Utility.alertDialog( url.replace("{0}",Xrm.Page.context.getClientUrl()).replace("{1}", Xrm.Page.data.entity.getEntityName()).replace("{2}", encodeURIComponent(Xrm.Page.data.entity.getId())));
}
HTH! Please leave your feedback on comments section!
No comments:
Post a Comment