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
SharadSharad 

How to call VF page from S-control ?

 

Due to the limitation on fixed height in page layout for VF page component. I decided to embed S-Control instead of VF page in page layout. For that, I would like to call my VF page from S-control.

 

Not sure, if this is possible and how to do that.

 

Appreciate any reply to help me advance in my development.

 

 

Thanks !

Sharad

mtbclimbermtbclimber

The only way to "embed" a Visualforce page within an scontrol is to use an iframe.

 

 

SharadSharad

Thanks. Appreciate if you can you please provide a code snippet for reference..

 

Thanks for your help !

 

Sharad

mtbclimbermtbclimber

<iframe src="https://c.YOURINSTANCE.visual.force.com/apex/mypage" height="200">

 

 

Message Edited by mtbclimber on 02-07-2009 01:12 PM
SharadSharad

Thanks It worked. Now, to avoid double tabbing, I used the javascript function as follows. I want to show the opportunity detail page, on which page layout, I have included the following S-Control, which in turn calls the VF page the way you mentioned above.

 

<script language="Javascript">
function redirect() {
parent.frames.location.replace('?retURL=%2F{!Opportunity.Id}');
}
redirect();
</script>

<iframe src="https://<my_instance_nm>.salesforce.com/apex/<mypagename>?id={!Opportunity.Id}" height="200">

 

 

 

When I use the above code, I get the following error:

 

URL No Longer Exists

and redirected to the following URL:
https://<my_instance_nm>.salesforce.com/servlet/servlet.Integration?retURL=%2F<Opportunity_Id>

 

 

Am I using wrong value of retURL ? I tried several options but none of them worked.

 

Thanks !

Sharad

mtbclimbermtbclimber

It's not clear what your objective is since we can't see what is calling redirect. Assuming it's a hyperlink the best way to avoid double tabbing is to embed a hyperlink with a target of "_top".   Not sure what you are doing exactly with the retURL param but you should know that we make no guarantees about that parameter name/function never changing.

 

Can you try using the code paste mechanism in the rich text toolbar next time? Click this button:

 

Thanks

SharadSharad

<iframe src="https://<my_instance>.salesforce.com/apex/<my_page>?id={!Opportunity.Id}" height="200">

My only objective is to call my VF page from the above mentioned S-Control. When I use just the iframe to call my VF page, it shows the complete window inside that section of Opportunity detail page, where I included this S-control (In the page layout)

 

 

I need to avoid double-tabbing and should only display the contents of my VF page in that block of page. Help me with this.

 

Thanks !

Sharad

 

 

 

SharadSharad

The simplest solution would have been to include the VF page itself in page layout. But, due to the fixed height issue, I had to choose different route to achieve the same, thinking that S-control would resolve the issue but I have my VF page ready which I want to use for display.

 

So, I am trying to call VF page from S-control and now stuck in double-tabbing issue. I hope this should clear the ultimate objective.

 

Appreciate your help.

 

Thanks !

Sharad

 

 

mtbclimbermtbclimber
Does your inlined page have the showHeader attribute set to false?
SharadSharad

Hi..

 

It did resolve the problem. Thanks for that.

 

But, the original problem still remain the same. The content of my VF page is variable and it height varies depending on content and the S-Control that I included in page layout have fixed height which shows white background if content is less in page and don't show the whole content within that block if it is more (or can display scrollbar if I enable them) which I don't want.

 

Is there a way to adjust the height according to the content through S-control. (I could not find that in VF page)

 

Thanks !

Sharad

mtbclimbermtbclimber

No, we do not support resizing inline page layout elements (scontrols or Visualforce pages) to fit their content today.

 

You should really not be using scontrols now anyway since they are deprecated and down the road will be de-supported.

SharadSharad

In one of the pdf I read about resizing, and provide the following code, but is not working. It always takes the height of 150, when I tried to print through alert

 

<html> <head> <script type="text/javascript"> function resizeIframe() { var me = window.name; if (me) { var iframes = parent.document.getElementsByName(me); if (iframes && iframes.length == 1) { var height = document.body.scrollHeight; alert(height); iframes[0].style.height = height + "px"; }}} </script> </head> <body onload="resizeIframe()" > </body> </html>

 

mtbclimbermtbclimber

Right, javascript solutions like the one you reference will not work with Visualforce because the browser security model will block that code from running. Have you checked your javascript console? I expect there is an error there.

 

This is because Visualforce runs in a separate domain from the containing standard detail page.

 

You could just override the detail page for your given object and rebuild the page itself in Visualforce, then there will be no iframe and no resize issues.

SharadSharad

 

Ya. That's right. I could do that, but there again had some challenges in regard to where I can display this piece of code. As I wanted to display before related lists of that object so I truned off the related lists and called each one of them individually after writing this piece of code. I used <apex:detail> tag.

 

I belive, I can't use detail tag as I want to show this piece of code in between sections of that detail page.

 

 

Thanks !

Sharad