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
Enara MarcosEnara Marcos 

Hide a button from home page component

We have an opportunity line custom button in the opportunity line related list of the opportunity page layout. This button must be showed only when the country of the oportunity is one of a list (list indicated in a custom setting). This dependency is not corresponds to profiles (because some profiles can manage more than one country).

Our solution is the create an html home page component to put it as a narrow component. We can hide the button thanks to jquery, but we need to do 2 queries to known if the button should be hidden or not. We can't achieve it.

So, we decided to do the same with visualfoce home page component as a narrow componet, however, it is not possible to hide the button (we can't get elements outside the visualforce) or we don't know how to do it.

Is there any solution for this goal?
Best Answer chosen by Enara Marcos
Enara MarcosEnara Marcos
I have a solution. 

I need to hide a button X inside the opportunity product related list of opportunity page layout. The condition to hide it, is wether the country of the opportunity is not in a custom setting.

Solution:

- create new opportunity product button Y: onclick javascript
- create an html home page component Z as a narrow component and add it to all home page layouts

* html home page component Z must click the button Y.
* button Y must hide itselft and calls to the custom setting. If the opportunity country not corresponts to a value of the custom setting record, then button Z must hide button X.

All Answers

bob_buzzardbob_buzzard
At present, no.  Once you go Visualforce the browser's same origin policy will stop you accessing elements in the main page.  However, using an html home page component is only a short term solution, as this capability is scheduled to be removed come Summer 15:

http://bobbuzzard.blogspot.co.uk/2014/06/javascript-in-salesforce-home-page.html
Enara MarcosEnara Marcos
I have a solution. 

I need to hide a button X inside the opportunity product related list of opportunity page layout. The condition to hide it, is wether the country of the opportunity is not in a custom setting.

Solution:

- create new opportunity product button Y: onclick javascript
- create an html home page component Z as a narrow component and add it to all home page layouts

* html home page component Z must click the button Y.
* button Y must hide itselft and calls to the custom setting. If the opportunity country not corresponts to a value of the custom setting record, then button Z must hide button X.
This was selected as the best answer