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.
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.
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))
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.
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:
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?
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.
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.
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/
Thank you! Unfortunately, this approach does not show the folder structure inside the linked location
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/
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,269 Super User 2024 Season 2
Martin Dráb 230,198 Most Valuable Professional
nmaenpaa 101,156