+ Start a Discussion

Need to close the popup window when i click on a link


I have embedded a VF page on Contacts, which pulls the campaigns for the said contact an end-user selects. I have created a 'Add to Campaign' button on this VF page, when I click on this button, it opens a window with standard filters like 'My Active  Campaigns', 'My Camapaigns', 'All Active Camaigns', 'All Campaigns'. When I select a campaign, the pop window does not close on it own.

Here is the code sample I am using for implementing this functionality;

<apex:page standardController="Contact" sidebar="false" recordSetVar="Contacts" extensions="CampaignRecords">
    <script type="text/javascript">
    function openNewPage(){
        var win='/_ui/common/data/LookupPage?lkpr=0031a000003tqzP&lktp=701&enableScopes=1&addToCampaign=1&retURL=%2F0031a000003tqzP';
        openIntegration(win, 'height=500,width=700,location=no,resizable=yes,toolbar=no,status=no,menubar=no,scrollbars=1', 1) 
        return false;  
    var previousOnload = window.onload; 
    window.onload = function() { if (previousOnload) { win.close(); }  }
    <apex:form >
        <apex:sectionHeader title="Campaign History" subtitle=""/>
        <apex:pageBlock id="campaigns">
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Type All" reRender="TabRefresh" >
                    <apex:param name="blTypeAll" assignTo="{!bltypeEmail}" value="TypeAll"/>
                <apex:commandButton value="Type Email" reRender="TabRefresh" >
                    <apex:param name="blEmail" assignTo="{!bltypeEmail}" value="Email"/>
                <apex:commandButton value="Type Others" reRender="TabRefresh"  >
                    <apex:param name="bltypeEmail" assignTo="{!bltypeEmail}" value="typeOthers"/>
                <apex:commandButton value="Add to Campaign"  onclick="return openNewPage()" >
            <apex:outputPanel id="TabRefresh">
                <apex:pageBlockTable value="{!campgn}" var="o" rendered="{!NOT(ISNULL(campgn))}">
                    <apex:column value="{!o.Name}"/ >
                        <apex:column value="{!o.Status}"/ >
                            <apex:column value="{!o.Type}"/ >
In the controller - make the methods that your commandButton's are calling, pageReference methods, and re-direct to the contact record again.
Hi Jeffrey,
I am calling JS function on 'Add to Campaign' button in VF page. So, I don't think I can return pagereference from JS. Do you agree??