
HI SF Success community!
I created a nice inline VF page that makes the layout look nicer by grouping all of the related lists into subtabs. Subsequently, I had to remove the Related Lists from the main Page Layout. Now, I am realizing that Salesforce1 mobile app only picks up related lists if they are added the manual way (not through VF code) to a regular page layout.
Does anyone know of a creative way around this issue? I would like to keep the subtabs of related lists as an embedded VF page, but I would also like to see certain (or all) related lists on a mobile device.
Many thanks!
Max
Hi Max,
I played with that idea a bit and these are my findings so far:- Since an inline VF page is embedded via IFRAMES and does not necessarily come from the same domain as your parent SF page, you cannot access the parent page via JS
- You can however add a custom component to your sidebar and inject the JS there
The following steps describe how to do that.
Keep in mind, that this is a very simple solution and there are most likely a lot of ways to improve this even further...- Create a custome home page component (Setup > Customize > Home > Home Page Component > New Custom Component)
- Give it a name (a unique distinctive one, like "HIDE_RL" and select HTML area, click next
- Select "Narrow", check the checkbox "Show HTML" and paste this code:
<script>
uriItems = top.location.href.split('/');
if(uriItems[uriItems.length - 1].length == 15 && uriItems[uriItems.length - 1].substring(0, 3) == 'a00')
{
window.onload = function () {
for(var i = 0; i < parent.getElementsByClassName('bRelatedList').length; i++)
{
parent.getElementsByClassName('bRelatedList')[i].style.display = "none";
}
}
}
sidebarItems = top.getElementsByClassName('sidebarModule');
console.debug(sidebarItems.length);
console.debug(sidebarItems[3]);
for(var i = 0; i < sidebarItems.length; i++)
{
if(sidebarItems[i].firstChild.firstChild.nodeName == 'H2' && sidebarItems[i].firstChild.firstChild.textContent == 'YOUR COMPONENT NAME')
{
sidebarItems[i].style.display = 'none';
}
}
</script>
- You'll need to replace the underlined elements.
- Replace 'a00' by the object identifier for the object you want to hide the related lists for. You can get the correct string by opening an arbitrary record in the detail view and take the first three characters from the record ID.
- Replace 'YOUR COMPONENT NAME' by the name you entered for the component
- Click Save
- Now go to Setup > Customize > Home > Home Page Layouts and edit the layout. Check your new component and save
- Last but not least, go to Setup > Customize > User Interface and enable "Show Custom Sidebar Components on All Pages"
In my test scenario this does the
- Hide all related lists on the detail page of my object (a00)
- Hide the custom homepage component on all pages
Let me know if this works for you!
Best regards,
Chris
visuallifecycle.net