i, I am trying to hide activities tab in social pane in dynamics 365. Below is the JS code, but I keep getting the code when form loads. I believe the event handler is correctly set. Please advise
function HideSocialPaneItems() { var tabs = ["ACTIVITIES"]; for (var tabsid = 0; tabsid < tabs.length; tabsid++) { HideTabs(tabs[tabsid]); } } function HideTabs(socialPaneType) { var ctrlElement = document.getElementById("header_notescontrol"); if (ctrlElement.children != null && ctrlElement.children.length > 0) { for (var ele = 0; ele < ctrlElement.children.length; ele++) { var ctrl = ctrlElement.children[ele]; if (ctrl.title == socialPaneType) { ctrl.style.display = "none"; if (ele + 1 < ctrlElement.children.length) { ctrlElement.children[ele + 1].click(); return; } else if (ele - 1 >= 0) { ctrlElement.children[ele - 1].click(); return; } } } } }
*This post is locked for comments
@sdnd2000
Hello, I'm trying to accomplish the same thing
Can you please share the solution to hide activities and post for an entity
Thanks
I will not pretend to understand exactly what you are doing but I see a similar error when I try to refresh the annotations list using remarkably similar code :(
However, for hiding tabs, can't you more simply use something like this: Xrm.Page.ui.tabs.get("tab_TOD").setVisible(false);
Why are you trying to click on the child elements? Also, have you tried enabling CRM365's "Legacy Form rendering" - seems to me that should be unnecessary but it was deemed necessary on a related thread:
I got it to work by modifying Alex Shlega's script. It didn't work with ", I had to use '
Here's my JS:
function HideSocialPaneItems() { var tabs = ["NOTES"]; for (var tabsid = 0; tabsid < tabs.length; tabsid++) { HideTabs(tabs[tabsid]); } } function HideTabs(socialPaneType) { var ctrlElement = document.getElementById('header_notescontrol'); if(ctrlElement == null) ctrlElement = window.parent.document.getElementById('header_notescontrol'); if(ctrlElement == null) return; if (ctrlElement.children != null && ctrlElement.children.length > 0) { for (var ele = 0; ele < ctrlElement.children.length; ele++) { var ctrl = ctrlElement.children[ele]; if (ctrl.title == socialPaneType) { ctrl.style.display = "none"; if (ele + 1 < ctrlElement.children.length) { ctrlElement.children[ele + 1].click(); return; } else if (ele - 1 >= 0) { ctrlElement.children[ele - 1].click(); return; } } } } }
This should work for either form type (legacy or not):
function HideSocialPaneItems() { var tabs = ["ACTIVITIES"]; for (var tabsid = 0; tabsid < tabs.length; tabsid++) { HideTabs(tabs[tabsid]); } } function HideTabs(socialPaneType) { var ctrlElement = document.getElementById("header_notescontrol"); if(ctrlElement == null) ctrlElement = window.parent.document.getElementById("header_notescontrol"); if(ctrlElement == null) return; if (ctrlElement.children != null && ctrlElement.children.length > 0) { for (var ele = 0; ele < ctrlElement.children.length; ele++) { var ctrl = ctrlElement.children[ele]; if (ctrl.title == socialPaneType) { ctrl.style.display = "none"; if (ele + 1 < ctrlElement.children.length) { ctrlElement.children[ele + 1].click(); return; } else if (ele - 1 >= 0) { ctrlElement.children[ele - 1].click(); return; } } } } }
Like I said, getElementById always returns null for non-legacy forms. What exactly Microsoft has done there to make it work this way - no idea.. I'd actually love to understand that myself:)
Here is the part that applies to the legacy forms:
"and then you need to make one change under Administration -> System Settings -> General."
It works, I just tried.. what happens in the next version is known to Microsoft only:)
it worked, any reason for this?
Yes, that's exactly what I meant and that's exactly what that link is about.
document.getElementById("header_notescontrol");
This returns null
Therefore, a call to ctrlElement.children fails with that error you have on the screenshot.
Try legacy forms and see if that helps
Sorry, I put wrong image, now I updated the image, it shows "Cannot read property 'children' of null" , that is not compatibility issue, right?
Hi sdnd,
as Andrii mentioned before, this is all unsupported.. You can have a look at this thread:
community.dynamics.com/.../229475
I did not try, but, funny enough.. it seems that we can't use getElementById with new form rendering - legacy form rendering may help, but that will probably affect other things(performance etc) and might end up being completely unsupported in the future.
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,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156