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
LATHA RAJLATHA RAJ 

Send Email from custom object launches VF page

Hi 
I have custom object where i want the Send Email button and onclick it should lauch VF page.How i achieve this...
Best Answer chosen by LATHA RAJ
NagendraNagendra (Salesforce Developers) 
Hi Latha,

Please try the code below;
Visual Force Page:

<apex:commandButton value="Send" id="email" onclick="OpenVfpage"('{!str}');return false"/>

<script>
&nbsp;&nbsp;
&nbsp; function OpenVfpage(pid){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var newwindow = window.showModalDialog("/apex/MYVFP?id="+pid, 'open page','_blank','scrollbars=yes,toolbar=no,status=no);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newwindow.focus();
&nbsp;&nbsp;&nbsp; }
</script>

Apex Controller:

public string str{get;set;}

public constructor()
{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;str=&nbsp;ApexPages.currentpage().getParameters().get('recordid');//I have used this str in your onclick method above in VF page.
}
Hope this helps.

Thanks,
Nagendra.