Activity Forums Salesforce® Discussions How to call a parent window function in a child window in a salesforce VisualForce page?

  • Vikas Kumar

    Member
    January 25, 2017 at 5:13 am

    Hi sushant,

    you can try something like this

    VF page

    <apex:page controller="LookupMainController">
    <apex:form >
    <apex:pageBlock title="Lookup">
    <apex:pageBlockSection columns="1">
    <apex:pageBlockSectionitem >
    <apex:outputLabel value="Account"/>
    <apex:outputPanel >
    <apex:inputHidden value="{!accountId}" id="targetId" />
    <apex:inputText size="40" value="{!accountName}" id="targetName" onFocus="this.blur()" disabled="false"/> <a href="#" onclick="openLookupPopup('{!$Component.targetName}', '{!$Component.targetId}'); return false">Lookup</a>
    </apex:outputPanel>
    </apex:pageBlockSectionitem>
    </apex:pageBlockSection>
    <apex:pageBlockSection >
    <apex:pageBlockSectionitem >
    <apex:commandButton value="Get Contacts" action="{!findContacts}"/>
    </apex:pageBlockSectionitem>

    </apex:pageBlockSection>
    </apex:pageBlock>
    <script>
    var newWin=null;
    function openLookupPopup(name, id)
    {
    var url="/apex/LookupExamplePopup?namefield=" + name + "&idfield=" + id;
    newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
    if (window.focus)
    {
    newWin.focus();
    }

    return false;
    }

    function closeLookupPopup()
    {
    if (null!=newWin)
    {
    newWin.close();
    }
    }
    function fillIn(name, id)
    {
    var winMain=window.open("https://vikas1st-dev-ed--vikasapp.ap2.visual.force.com/"+id);
    }
    </script>
    </apex:form>
    <apex:pageBlock >
    <apex:pageBlockSection >

    <apex:pageBlockTable value="{!contacts}" var="contact">

    <apex:column headerValue="LastName">
    <apex:outputLink value="#" onclick="fillIn('{!contact.LastName}', '{!contact.id}')">{!contact.LastName}</apex:outputLink>
    </apex:column>
    <apex:column headerValue="FirstName" value="{!contact.LastName}"/>

    </apex:pageBlockTable>

    </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:page>

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos