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
sfadm sfadmsfadm sfadm 

How to migrate custom lookup visualforce page to Lighting Experience?

I have a custom lookup visualforce page implemented exactly as it is explained here (http://bobbuzzard.blogspot.com/2010/09/visualforce-lookup.html)
I need to know how to migrate my custom lookup visualforce page:
<apex:page id="SearchAccount" showHeader="false" sidebar="false" controller="SearchAccountController">
    <apex:includeLightning  />
<script>
      // 'LookupVfApp' Is Lightning Application Name
    $Lightning.use("c:LookupVfApp", function() {

      // 'LcForLookupVf' is Lightning Component Name
    $Lightning.createComponent("c:LcForLookupVf",
    {
      // Set Lightning Component Attributes Property before creating Lightning Component In Visualforce page
        label : "Press Me!"
    },
   "LcDisplayId",
    function(component) {
    });
    </script>

    <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();
                }
             populateNumber();     
            }
        </script>

        <apex:actionFunction name="populateNumber" action="{!PopulateAccNumber}" rerender="accinfo, msgs" />

       <apex:outputPanel> 
       <apexoutputText value="Name"/>
       <apex:outputPanel>
            <apex:inputHidden value="{!accountId}" id="targetId" />
            <apex:inputText value="{!laccountName}" id="targetName" onFocus="this.blur()"/>
       <div id="LcDisplayId"></div>
                    <!--  <a href="#" onclick="openLookupPopup('{!$Component.targetName}', '{!$Component.targetId}'); return false">Lookup</a> -->                
        </apexoutputPanel>  
        </apex:outputPanel>
        <apex:outputText value="{!accountnumber}" id="accinfo"/>
    </apex:page>

So far I created a LcForLookupVf.cmp lightning component:
<aura:component implements="force:appHostable,force:lightningQuickActionWithoutHeader,flexipage:availableForAllPageTypes" access="global">

    <ui:button label="navigateToURL" press="{!c.gotoURL}" />

</aura:component>
The it is explained here (https://salesforce.stackexchange.com/questions/156425/how-to-navigate-to-vf-page-from-a-lightning-component-with-javascript) I Created a LcForLookupVfController.js:
gotoURL : function(component, event, helper) {
    var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
        "url":"vfpage url"
    });
    urlEvent.fire();
Created a LookupVFApp.app Lightning Application:
<aura:application access="GLOBAL" extends="ltng:outApp"> 
    <aura:dependency resource="c:LcForLookupVf"/>
</aura:application>
Please advise how to add the openLookupPopup function:
function openLookupPopup(name, id)
    {
        let url = new URL("{!URLFOR($Page.opptyStepMailPopup)}");
        let params = url.searchParams;
        //Add parameters
        params.append('namefield', name);
        params.append('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;
    }
to my LcForLookupVfController.js and be able to navigate the Lookup link to pop up and open the
User-added imagelookup window?