Home page components get added to a homepage layout that are assigned per profile, now if I want to hide the component for specific users in the profile is it possible to do so ?
eg: sysadmin has user A , user B, user C.
If I have to hide the homepage component (nothing but a IFRAME where src = apex page) for user C and show it only to A and B is it even possible?
Is there some way to hide it using Java script?
I was able to find some reference and got down to this
<div class="iframe">
<iframe src="/apex/page" style="width:1000px;height:400px;"></iframe>
<style type="text/css">
.iframe{display:none !important;} // hide the iframe itself
h2{display:none !important; //salesforce always uses h2 for custom component headings thus this takes cares of hiding the component name, bad approach if there are other custom components, alternative solutions would be most helpful :)
</style>
</div>
*the above script works awesome and hides the custom component but i want to scrap the user name of the user from the top of the page and hide the component.*
By inspecting the element i found the class name to be :
**<h1 class="currentStatusUserName"><a href="/_ui/core/userprofile/UserProfilePage">username test user</a>**
</h1>
can someone point me how to scrap the username using jScript to actually compare who logged in and hide the custom homepage component?
Any help will be appreciated.
thanks a lot!!
*UPDATE : Harcoded user Id to make the component only visible for specific users *
Code for refrence :
<div class="iframe">
<iframe src="/apex/page" style="width:1000px;height:400px;"></iframe>
</div>
<script>
// moved from the top div and found that the class name for username on the home page as
currentStatusUserName and used querySelectorAll since IE8 does not understand getElementsByClassName
var userid = UserContext.userId;
var div_hide_1 = document.querySelectorAll('.iframe')[0];
var div_hide_2 = document.getElementsByTagName('h2');
if(userid == 'someuserid'){
}
else{
for(i=0;i<div_hide_2.length;i++){
if(div_hide_2[i].innerHTML == 'Component Test'){
div_hide_1.style.display = 'none';
div_hide_2[i].style.display = 'none';
}
}
}
</script>