Add a button on Form Ribbon in Dynamics 365 Customer Engagement using Ribbon workbench and Form Context to Display Form Field Value
In this post we will see how to add buttons on an Entity form and attach a JavaScript event to interact with Form Fields using Form Context except Xrm.Page as Xrm.Page will not be used in future as per recommended by Microsoft.
So let’s start. First we have to create a JavaScript web resource named as “ribbon.js” and add a function with below code. And publish the web resource.
function ribbonmsg(primaryControl) { var formContext = primaryControl; alert("Hello" + formContext.getAttribute("lastname").getValue()); };
Next we have to create a solution and add the entity for which you want to add button. For us we will use Contact entity.
Now download Ribbon Workbench and Import to Dynamics 365 using below URL.
https://www.develop1.net/public/rwb/ribbonworkbench.aspx
After import operation complete refresh the screen. You will see the below option on solutions window.
Then click on the Ribbon workbench option. It will open the Ribbon Workbench in a new window asking to choose a solution. Select the solution and proceed.
After selecting the OK button it will display the Unified Area where drag a button and drop at the correct location on Forms TAB as displayed below.
Now change the Label to “My Button”. Then add new command to select JavaScript function as given below.
Now choose the JavaScript library and the function and CRM Parameter as “primary control”
After this step associate the Command with Command Definition option of Button.
Now we are done. Click Publish. It will take couple of seconds to Publish. Now we will test the button.
Navigate to Sales, refresh the whole screen and Open any Contact record Form.
On clicking the button you will see the below alert.
That’s all. Thanks for reading. For training requirements contact below.
Call: 8328865778 Email: support@sh034.global.temp.domains