Are you looking to customize the display of related entities in Dynamics 365 CE? In this blog post, we will explore how to hide related entities in the related tab using JavaScript. This can be particularly useful when you want to streamline the user interface or display only relevant information based on specific conditions. Using the Dynamics JavaScript library, we can achieve this customization easily. Let's dive into the steps and code snippets to accomplish this task. Step 1: Accessing Navigation Items To begin with, we need to access the list of navigation items within the related tab. We can do this using the Xrm.Page.ui.navigation.items collection. var navItems = Xrm.Page.ui.navigation.items.get();
This line of code retrieves all the navigation items within the related tab. Step 2: Hiding Related Entities Once we have access to the navigation items, we can hide specific related entities based on their names. For example, let's say we want to hide the "Contacts" navigation item. var navItemName = "Contacts"; // Specify the name of the navigation item to hide var navItem = navItems.get(navItemName); if (navItem) { navItem.setVisible(false); }
In this code snippet, we first retrieve the specific navigation item by its name ("Contacts" in this case) using navItems.get(navItemName). If the navigation item exists (navItem is not null), we then use navItem.setVisible(false) to hide it. Putting It All Together Here's how you can combine the above code snippets to hide related entities in the related tab: var navItems = Xrm.Page.ui.navigation.items.get(); var navItemName = "<navigation item name>"; // Specify the name of the navigation item to hide var navItem = navItems.get(navItemName); if (navItem) { navItem.setVisible(false); }
Replace <navigation item name> with the actual name of the navigation item you want to hide. Conclusion By leveraging the Dynamics JavaScript library and the setVisible method, we can easily customize the display of related entities within the related tab in Dynamics 365 CE. This level of customization enhances user experience and ensures that users only see the relevant information they need, improving productivity and clarity within the CRM system.