Microsoft Release 2020: Open dialog on button click

Today, we will see how to open an entity main form on top on another entity main form without navigating from one entity to another.

Let’s take an example of Order and Product entity. So, when a user clicks on Order entity main form ribbon button then Product entity main form dialog should get pop up above Order entity main form instead of navigating to Product entity.

Steps to achieve the above functionality:

  • Get the Ribbon Workbench solution installed on the CRM instance.
  • Create a new solution and add Order entity.
  • Create a new web-resource of JavaScript type and add the below JS code in it.
  • Add the web-resource in the solution.
function DialogPopUp()
{
Xrm.Navigation.navigateTo(
{
pageType: "entityrecord",
entityName: "product",
formType: 2
},
{
target: 2,
position: 1,
width: {
value: 70,
unit: "%"
}
});
}

Now, lets open the solution inside ribbon workbench.
Click on Open Solution button on the left top this with pop up a window. Using which we get the ability to select the desired solution which we want to open inside ribbon workbench.

Figure 1: Ribbon Workbench

Drag the Button option from ToolBox menu and place it on the Order form ribbon. Rename the button by inserting a new name in the Label. I have given Product Dialog – the same would get reflected on the Order main form.

Figure 2: Create button on Order entity

Now create a new command by clicking on the “+” icon. This is where we call the JavaScript webresource as shown in the below image and provide the JS function name(DialogPopUp) inside the Function Name field.

Figure 3: Create a new command for calling JS webresource

Enable the Display Rule to True. For this click in the “+” icon next to Display Rule and

Figure 4: Enable Display Rule

Select the button rule as shown in the below image and tag the command inside Command drop-down.

Figure 5: Tag command inside Command drop-down

Now, we need to save our changes therefore hit the Publish button. Post that go back to Order entity and refresh the browser.

Figure 6: Product Dialog button on Order entity.

Hit the Product Dialog button and we should get the Product entity main form on top of SalesOrder entity.

Figure 7: Product Dialog on SalesOrder Entity

Happy CRM!

Create your website with WordPress.com
Get started
%d bloggers like this: