Saturday 16 March 2024

How to Hide Related Entities in Related Tab Using JavaScript

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.


Saturday 22 April 2023

D365 CE - JS check the client is offline or online

Greetings, Dynamics Techies! As the world of Dynamics evolves, we are faced with the challenge of developing JavaScript that can seamlessly transition between online and offline modes. With the introduction of the offline profile, this challenge has become more pressing than ever before. 

 To help navigate these waters, I am excited to announce a new series of blog posts where I will be sharing my learnings and insights on developing JavaScript for both online and offline modes in Dynamics. Whether you're a seasoned developer or just starting out, these posts will provide valuable tips and tricks for ensuring your JavaScript is compatible with both modes, allowing for a smoother, more efficient user experience. 



 So, join me as we explore the world of Dynamics JavaScript development and discover how we can make the most of this exciting technology. Together, we can tackle the challenges of offline and online modes and unlock the full potential of Dynamics.


var clientContext = Xrm.Utility.getGlobalContext().client;
if (clientContext.getClientState() === "Offline") {
    // User is offline
} else {
    // User is online
}

Happy Learning!

Reference:

https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-utility/getglobalcontext/client#syntax-1

Saturday 11 January 2020

D365 CE - Rename organization/Instance url and name in cloud - Powerplatform

After creating the organization/Instance in cloud, we may want to rename the organization URL to fix a typo or we have changed our mind.

Can we do it?  => yes, of-course 

Note: The organization unique name cannot be modified!


How to fix it?

Consider we need an dev organization for Contoso. By mistake we created as ContosDev instead of ContosoDev

  1. Go to https://admin.powerplatform.microsoft.com/environments
  2. Open the environment(by clicking Constosdev cell) and click "Edit" 
  3. Update the URL and name as needed




































Voila, now the url is updated!

Wednesday 6 November 2019

D365 CE - Duplicate detection approach and options



Hello All,

It feels great to be back with an interesting topic around duplicate detection and approaches.

Duplicate detection is essential to maintaining data integrity and quality in any system and when it comes D365 though there are multiple options to achieve this we are going to concentrate on the following four

1. Duplicate Detection Rules

Duplicate detection rules are out of the box way to manage duplicates. The same can be configured at the UI level.
  • Not enforced and users can override optionally
  • Works within current users access, so there is a chance that duplicates beyond current users access are not considered
  • Needs to be specified explicitly while creating records via OrgService/WebApi

2. Alternate keys
MSCRM alternate Keys are handy in performing duplicate detection and the alternate keys are primarily used for simplifying Integration and Migration activities. Beyond that, it implements a unique constraint for one column or combination of columns.

  • Robust and applies across the board. No need for impersonation
  • Covers UI, Import, OrgService and WebApi
  • Allows null values and duplicate detection is not applied here
  • It also can be used for upsert, retrieve, update and delete. 
  • Errors are system defined and cannot be customized
3. Plugin/Workflow
We can write our own logic to detect and avoid duplicates using plugin and workflows.
  • Allows custom error messages
  • Provides better control on duplicate detection logic
  • Covers UI, Import, OrgService and WebApi
  • Works within the current user's access, so there is a chance that duplicates beyond the current user's access is not considered. Needs impersonation.
4. JavaScript
Like plugin, we can achieve this using a simple JavaScript but the same has its own limitations
  • Covers only UI
  • Allows custom error messages
  • Provides better control on duplicate detection logic
  • Works within the current user's access, so there is a chance that duplicates beyond the current user's access is not considered. Needs impersonation.