Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
To add the View hierarchy button to the forms or grids for a table, the table must first be added to your application. While the View hierarchy button is enabled by default on the Contact, Opportunity, Lead, and Account forms and grids, as an administrator, you can add the View hierarchy button to all other tables.
Add the table to the application
You have to add the table to the application in order to customize the behavior of forms and grids associated with the table. Follow these steps:
- Sign in to the Power Apps maker portal.
- Select Apps from the left navigation, select All to show all applications and then select your application. The default application for Dynamics 365 Sales is Sales hub.
Note
- Ensure that the correct environment is selected in the top-right corner of the page.
- If you don't want the table shown under the Customers section, deselect the Show in navigation option. The table is added to the All other pages section in the left navigation.
- If the table is already included in either Navigation or All other pages, then go to Add button to command bar section to add the button to the command bar.
- Go to Navigation > Customers and select an existing table under which you want to add a new table.
- On the command bar, select the drop-down chevron and select Dataverse table.
- Search and add the Hierarchy Configurations table.
- Save and publish.
The table is added to the application.
Add button to command bar
To add the View hierarchy button to a form or a grid command bar, follow these steps:
You must have administrator privileges.
Sign in to the Power Apps maker portal.
Select Apps from the left navigation, select All to show all applications and then select your application. The default application for Dynamics 365 Sales is Sales hub.
Note
Ensure that the correct environment is selected in the top-right corner of the page.
On the app home page, select more options (...) next to the table name, and then select Edit command bar.
Note
If you don't see the table, add the table to your app. More information: App navigation in model-driven apps.
On the edit command bar dialog, choose Main grid or Main form depending on where you want to add the command.
Select the existing command bar button after which to add the new button, then select + New > Command.
New command option is available next to the selected command. The following screen is an example Main form:
On the new command bar pane, enter the following information depending on whether you're adding the button to a form or a grid.
For Main form:
Field name Description Label Enter a label for the command. For example, View hierarchy. Icon From the list, select Use web resource and then select Add web resource. In the Add image web resource dialog box, search and add HierarchyViewerIcon.svg. Action Select Run JavaScript as the action type. Library Select LinkedInExtensions/HierarchyViewer/msdyn_HierarchyViewer.js from the list of available JavaScript libraries. If the library isn't available, select Add library and then add the library to the list. Function name Enter HierarchyViewer.RibbonRules.formShowHierarchyViewer.
Select Add Parameters and then add the following parameters:
- For Parameter1, from the dropdown list, selectPrimaryControl.
- For Parameter2, from the dropdown list, selectPrimaryEntityTypeName.
- For Parameter3, from the dropdown list, selectFirstPrimaryItemId.Visibility Select Show.
If you want to use a formula to control button visibility, select Show on condition from formula, open the formula bar, and add a function. For example, to allow navigation to the hierarchy only after the item is saved, enterNot(Self.Selected.Unsaved) && Self.Selected.State = 0.For Main grid:
Field name Description Label Enter a label for the command. For example, View hierarchy. Icon From the list, select Use web resource and then select Add web resource. In the Add image web resource dialog box, search and add HierarchyViewerIcon.svg. Action Select Run JavaScript as the action type. Library Select LinkedInExtensions/HierarchyViewer/msdyn_HierarchyViewer.js from the list of available JavaScript libraries. If the library isn't available, select Add library and then add the library to the list. Function name Enter HierarchyViewer.RibbonRules.formShowHierarchyViewer.
Select Add Parameters and then add the following parameters:
- For Parameter1, from the dropdown list, selectSelectedControl.
- For Parameter2, from the dropdown list, selectSelectedEntityTypeName.
- For Parameter3, from the dropdown list, selectFirstSelectedItemId.Visibility Select Show.
If you want to use a formula to control button visibility, select Show condition from formula and then add the formula. For example, to only allow navigating to the hierarchy when a row is selected, enterCountRows(Self.Selected.AllItems) = 1.
Save and publish.
View hierarchy option is added to the command bar for the selected table.To verify, open the app, go to the table where you added the button, and then select a record. You should see the View hierarchy option in the command bar.