Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to always show related entity (Documents) tab on Main Form?

Posted on by 287

There is no OOB functionality to show the Documents tab:

pastedimage1612532631025v1.png

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.

  • KVa Profile Picture
    KVa 287 on at
    RE: How to always show related entity (Documents) tab on Main Form?

    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))

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to always show related entity (Documents) tab on 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.

  • Suggested answer
    Frank Lee Profile Picture
    Frank Lee 4,616 on at
    RE: How to always show related entity (Documents) tab on Main Form?

    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

  • Aneeqa Pervaiz Profile Picture
    Aneeqa Pervaiz 240 on at
    RE: How to always show related entity (Documents) tab on Main Form?

    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?

  • Ashleigh Swayn Profile Picture
    Ashleigh Swayn 5 on at
    RE: How to always show related entity (Documents) tab on Main Form?

    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.

  • KVa Profile Picture
    KVa 287 on at
    RE: How to always show related entity (Documents) tab on Main Form?

    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.

  • Verified answer
    Wahaj Rashid Profile Picture
    Wahaj Rashid 11,319 on at
    RE: How to always show related entity (Documents) tab on Main Form?

    Hi,

    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/

  • KVa Profile Picture
    KVa 287 on at
    RE: How to always show related entity (Documents) tab on Main Form?

    Thank you! Unfortunately, this approach does not show the folder structure inside the linked location

  • Suggested answer
    Wahaj Rashid Profile Picture
    Wahaj Rashid 11,319 on at
    RE: How to always show related entity (Documents) tab on Main Form?

    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/

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.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans