function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BenPBenP 

Insert vf page with java to hide button

I need to hide the "New Note" button which I've found I can do with a java component via the sidebar.  I'd rather do this on a page layout basis if possible, so I thought I could stick the script in a hidden vf page.  Well, that's not working.  My java is below along with the page I made (I don't use the picklist part).  Is this possible, or did I just not create the page correctly?  Thank you for the help.

 

Java sidebar component:

<script type="text/javascript" 

src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<script type="text/javascript">   
/* Set your sidebar component, button, and picklist field labels here */   
var customComponentName = 'Hide new note button';   /*must equal the custom component label*/

var buttonLabel = 'New Note';  /*button to hide*/
 
var picklistLabel = 'My Picklist';    /*picklist to control when hid if applicable*/
  
$(document).ready(function(){         
/* hide the sidebar component from user */        
$('.htmlAreaComponentModule').find('h2:contains("'+customComponentName+'")').parent().parent().hide(); 
    
/* only hide button if picklist value is "High" */                   
var picklistValue = $('td.labelCol:contains("'+picklistLabel+'")').next().find('div').html();                   
var btn = $('input[value="'+buttonLabel+'"]');                                              
btn.hide();   
}); </script>

 VF page I created:

<apex:page standardController="Lead">
<script type="text/javascript" 

src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<script type="text/javascript">   
/* Set your sidebar component, button, and picklist field labels here */   
var customComponentName = 'Hide new note button';   /*must equal the custom component label*/

var buttonLabel = 'New Note';  /*button to hide*/
 
var picklistLabel = 'My Picklist';    /*picklist to control when hid if applicable*/
  
$(document).ready(function(){         
/* hide the sidebar component from user */        
$('.htmlAreaComponentModule').find('h2:contains("'+customComponentName+'")').parent().parent().hide(); 
    
/* only hide button if picklist value is "High" */                   
var picklistValue = $('td.labelCol:contains("'+picklistLabel+'")').next().find('div').html();                   
var btn = $('input[value="'+buttonLabel+'"]');                                              
btn.hide();   
}); </script>
</apex:page>

 

Anil SavaliyaAnil Savaliya

There is different scenario,have to check?

 

Home component  is assigned for page layout or not ?

Custom side component enable for all tab or not?

 

In Short,If in page where you want to hide ,On side bar home component ,If visible then fine.

 

Also ,Make add latest Javascript libarary ,I think,It's 1.10.1 

BenPBenP

I'd like to put this java in the page layout vs. the sidebar.  That way I can more easily control which profiles/pages have the button hidden.