+ Start a Discussion
saracsarac 

Custom button/s-control renders in hover box when pressed! Help...

Hello,

I have a number of custom "New" buttons which are located on a related list (of Opportunities) in the Contact record. The buttons are S-control buttons and are set to render in the same window with a side bar.

They work fine off of the related list - they just bring up a pre-populated opportunity record type. However, when you hover over the related list at the top of the Contact record and push one of the buttons, it renders the new page in the hover box!

Any help here?

Thanks!
Sara

Update: I have compared this custom button/s-control with another that comes with the non-profit template (both create membership opportunity records from a Contact and both are located on the opportunity related list in the contact record) and does NOT render in the hover when pressed, and they are *identical*. Same exact button attributes, and the S-control's Javascript is the same as well. This is a big problem for our client - I am thinking it must be a configuration issue. ?



Message Edited by sarac on 04-23-2008 12:09 AM
cgosscgoss
I've noticed similar behavior to what you've mentioned. Just to clarify my experience, it appears that if the s-control calls a redirect, the whole page refreshes. If the s-control renders content directly, it will render inline. Seems like a bug to me! In the NP template, I believe the buttons are pre-filling data in an existing edit form. They are doing this by constructing a URL in the s-control, then redirecting, thereby getting around this bug.

Please post back if you've found a solution to this.
Joseph FerraroJoseph Ferraro
i'm having the same issue, trying to hack around it.

i'll let you guys know if I come up with something.
sfdcfoxsfdcfox
Those little hovers are effectively inline frames, which is why they behave the way they do. It's not exactly a bug, but it is a rather unpleasant surprise if you're not expecting it. If at all possible, you should consider using an OnClick method to work around this. For example:
 
Code:
{!URLFOR($Action.Opportunity.New)}

This doesn't work with related list hovers though it works normally. To fix it, change it to JavaScript, and do this:
 
Code:
window.top.location.href = '{!URLFOR($Action.Opportunity.New)}'

You should be able to work around any type of URL problem using this simple JavaScript syntax. You can also open your S-Controls using URLFOR and this JavaScript, although your milage may vary. Alternatively, you can use a "breakout" script inside the s-control itself, as follows:
 
Code:
if(window.top.location.href != window.location.href)
{ window.top.location.href = window.location.href;
}

Include this code anywhere in your S-control's initialization scripts, and it will break out of whatever frames it might be placed in in this or any future release. This might be undesirable if you're trying to get your S-Control to appear inside tabs, though.
saracsarac
Hi there,

Unfortunately one can not use the URLFOR method if any of the queryparameter names are salesforce IDs (which a few of ours are due to how Salesforce names custom field input parameters). This is a post I wrote a while back, which was a disappointment to say the least!

I have been using the top reference in Javascript which only partially works - if you click the button in the hover, but then move the mouse off of the hover before the next page renders (not hard to do) then nothing renders. This is not the case for built in Hover buttons. Someone was looking into this issue, but I never heard anything back.

Thanks for your input,
Sara
Pradeepkumar Dani 5Pradeepkumar Dani 5
I am also getting same issue..Any work around for this?

Found Issue replication link : https://success.salesforce.com/issues_view?id=a1p30000000T3ttAAC
Ashwin KhedekarAshwin Khedekar
var openUrl = '/apex/vfSearchMoreContacts'; // path of VF page to be opened when the related list button is clicked
if(window.top.location.href != window.location.href) 

  //alert('hover window button clicked'); 
  parent.location.href = openUrl;
}
else
{
  //alert('related list button clicked'); 
  window.open(openUrl,'_self'); // _self opens VF page in the same tab
}

You can add alerts to see the values :-
alert('window.top.location.href is ' + window.top.location.href);
alert('window.location.href is ' + window.location.href);
They are different when the button is clicked in the hover window itself on the Contacts link on an account's detail page.

Detailed description :-
Suppose you have created a custom button on Contact called as "Search more contacts" of type related list button that will execute Javascript from Setup -> Customize -> Contacts -> Buttons, Links, and Actions -> New Button [Type = List Button, Behavior = Execute JavaScript]

This button will open a new Visualforce page called vfSearchMoreContacts.

If you hover on the Contacts link at the top of an account record and click on this button in that hover window itself, it will open the Visualforce page to be opened in that hover window itself. To open it in current tab, use code given above.