Notifications
Announcements
No record found.
There is no OOB functionality to show the Documents tab:
Is there some approach to always show the Documents tab using JS?
Using the Power Platform editor to show a subgrid is not an option becuase it does not show folder structures.
Hi,
Thank you for your query.
It is supported in Wave 2 release but only for (Account, Contact, Lead and Opportunity entity):
https://www.marksgroup.net/blog/dynamics-365-related-documents-now-display-on-records-main-form/
Thank you! Unfortunately, this approach does not show the folder structure inside the linked location
I found a hack to show the Documents tab on Load of the form.
The idea is register an onLoad function to setFocus() on the Documents navigation item, this opens the Documents tab automatically. Furthermore, if you need to show the default tab, you can set the focus to default tab. This way Documents tab is opened but navigation is set to main tab.
I registered following code on the load of Account entity:
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 (optional) var mainTab = formContext.ui.tabs.get("SUMMARY_TAB"); // Then move to Main Tab mainTab.setFocus(); }
Please see my blog for detailed steps:
https://crmlogs.wordpress.com/2021/02/07/dynamics-365-ce-show-documents-tab-by-default/
It's a hack, but it works, thank you. There is a method "setVisible" on the navigation item, but unfortunately it does not show the tab, you really have to change the focus.
The subgrid is actually an option because you can use script to change the view to the Document Associated Grid that has the folders. Use a script to simply change the view to the Document Associated Grid and then move back to main tab (similar to the end of Wahaj's script). The advantage of the subgrid on its own tab is that you can name the tab (instead of "Documents"), position it where you want it ("Documents" is always in the far right position). The "Documents" tab also has a disadvantage in that if you click on another related tab you lose the documents tab, plus the view takes up a lot more screen space when compared to using a tab with the subgrid.
Hello Wahaj Rashid
I am trying this out on a custom entity, it does not seem to work. For one, it opens up the form with the document associated tab as the main focus, and then also gives the pop up that the script has encountered an error - which is that the mainTab is null. The only change I have done here is to change the name of the main tab, replacing "Summary_Tab" in your case to the name of the main tab, which is "Main" in my case. Registered the script on form onLoad. Is there anything I am missing?
Here is a write up to set the Files tab to both custom entity/table or out of the box entity/table that may not have the Files tab by default:
How to Add SharePoint Document Files Tab to a Dynamics 365 Custom or Out of the Box Table (Entity) Main Form
It gives me the following error:
TypeError: Cannot read properties of null (reading 'setFocus') at Object.LockUnlockFieldsMainOther (crm-dev.axiscapital.com/.../Contact.js:548:21) at Object.LoadForm (crm-dev.axiscapital.com/.../Contact.js:267:29) at il.executeFunction (crm-dev.axiscapital.com/.../app.js at il.execute (crm-dev.axiscapital.com/.../app.js at crm-dev.axiscapital.com/.../app.js at i (crm-dev.axiscapital.com/.../app.js at V._executeIndividualEvent (crm-dev.axiscapital.com/.../app.js at V._executeEventHandler (crm-dev.axiscapital.com/.../app.js at Object.execute (crm-dev.axiscapital.com/.../app.js at w._executeSyncAction (crm-dev.axiscapital.com/.../app.js
I'm sure that all the naming's are correct but it still gives me this error.
It seems your navItem variable is null. This occurs because no navigation item for "navSPDocuments" is found. Did you enable Document Management in your entity? You can check by trying to open the Document Management manually. Alternatively, inspect the contents of items:
Xrm.Page.ui.navigation.items.forEach(e => console.log(e))
this.expandedTabs = function (executionContext) { let formContext = executionContext.getFormContext(); const navigations = formContext.ui.navigation.items; const tabs = formContext.ui.tabs; // Save reference to the currently expanded tab const focusedTab = tabs.get().find(tab => tab.getDisplayState() === 'expanded'); // Ensure the "Audit History" navigation item exists const auditNav = navigations.get("navAudit"); if (auditNav) { auditNav.setFocus(); // Set focus on the Audit History navigation item } else { console.warn("Audit navigation item not found."); } // Expand the Audit History tab const auditTab = tabs.get("auditHistoryTab"); if (auditTab) { auditTab.setDisplayState("expanded"); // Expand the Audit History tab } else { console.warn("Audit History tab not found."); } // Expand the Documents tab const documentsTab = tabs.get("documents"); if (documentsTab) { documentsTab.setDisplayState("expanded"); // Expand the Documents tab } else { console.warn("Documents tab not found."); } // Restore focus to the original tab (if it exists) if (focusedTab) { focusedTab.setDisplayState("expanded"); } else { console.warn("No previously focused tab found."); } };
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Siv Sagar 93 Super User 2025 Season 2
#ManoVerse 74
Martin Dráb 64 Most Valuable Professional