Wednesday 8 December 2021

Dynamics 365 CE: Show Documents tab on the forms by default

 SharePoint Documents are listed under Related – Documents tab. To improve UX, recently came across a requirement to show SharePoint Documents tab by default. This means, user no longer has to click on Related -> Documents to open the tab.

You might ask, as an alternative, we can add a Document subgrid to the form, which is a simple solution. However, Documents subgrid do not show the Folder Structure, which is something we need.

To achieve this, we need to play with formContext.ui.navigation.items.

Let’s dig in!

Problem

Open Document Tab by default (on load).

Solution

On load of the form, set focus on the document navigation Item to load the Documents tab. Then move back the focus to the main tab.

Here are steps to follow:

  • Create a new webresource or use an existing (as per your need).
  • Add following code to the webresource:

function openNav(executionContext) {

// get formContext

var formContext = executionContext.getFormContext(); 


// Get Nav. Item

var navItem = formContext.ui.navigation.items.get("navSPDocuments");


// First set focus on Nav. Item to open related tab
navItem.setFocus();


// get Main tab (replace it with your tab name)
var mainTab =  formContext.ui.tabs.get("SUMMARY_TAB");

// Then move to Main Tab
mainTab.setFocus();

}

  • In the solution, navigate to the desired entity (Account for this example), add the above webresource in the forms library (if not already).

  • Register this function on the onLoad of the form. Do not forget to pass execution context.
  • Save and Publish the form.
Result

As soon as user opens the form, Document tab is already shown:


The End..

MS D365 (CRM) Trial Environment Creation

1. Type " MS CRM Trail" Google 2.  Click on https://portal.office.com › Signup like the Image below 3. Get started with filling yo...