You need to sign in to do that
Don't have an account?

Bypass Salesforce Standard Account Lookup with Visualforce page
Greetings, I have been working on a Visualforce popup page that mimics Salesforce's Contact and Account Lookup Dialog and QuickCreate functionality as part of app I'm building for batch creating records for a custom object.
This VF page, based on Jeff Douglas's Rollup your own Salesforce Lookup Popup enables our users to create Contact records. Now I recently created another lookup like this one for accounts, where when a user types an account or looks up an account to connect a new contact to an existing Salesforce account. I added some Javascript to force the Account lookup to open and run the custom Account lookup I created, however, with the script, I still get the Salesforce standard lookup, where should I place this code (attached below) or what should I add to enable the custom page I built to open.
Hope it helps.
Code for the Visualforce page
The Script that should open the custom popup and bypass the standard Salesforce account lookup dialog
This VF page, based on Jeff Douglas's Rollup your own Salesforce Lookup Popup enables our users to create Contact records. Now I recently created another lookup like this one for accounts, where when a user types an account or looks up an account to connect a new contact to an existing Salesforce account. I added some Javascript to force the Account lookup to open and run the custom Account lookup I created, however, with the script, I still get the Salesforce standard lookup, where should I place this code (attached below) or what should I add to enable the custom page I built to open.
Hope it helps.
Code for the Visualforce page
<apex:page controller="ContactLookupControl" title="Search" showHeader="false" sideBar="false" tabStyle="Contact" id="pg"> <apex:form > <apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;"> <apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel"> <!-- SEARCH TAB --> <apex:tab label="Search" name="tab1" id="tabOne"> <apex:actionRegion > <apex:outputPanel id="top" layout="block" style="margin:5px;padding:10px;padding-top:2px;"> <apex:outputLabel value="Search" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/> <apex:inputText id="txtSearch" value="{!searchString}" /> <span style="padding-left:5px"><apex:commandButton id="btnGo" value="Go" action="{!Search}" rerender="searchResults"></apex:commandButton></span> </apex:outputPanel> <apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block"> <apex:pageBlock id="searchResults"> <apex:pageBlockTable value="{!results}" var="a" id="tblResults"> <apex:column > <apex:facet name="header"> <apex:outputPanel >Name</apex:outputPanel> </apex:facet> <apex:outputLink value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!JSENCODE(a.Name)}', false);self.close();" rendered="{!NOT(ISNULL(a.Id))}">{!a.Name}</apex:outputLink> </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >Account Name</apex:outputPanel> </apex:facet> {!a.Account.Name} </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >Street</apex:outputPanel> </apex:facet> {!a.MailingStreet} </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >City</apex:outputPanel> </apex:facet> {!a.MailingCity} </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >State</apex:outputPanel> </apex:facet> {!a.MailingState} </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >Postal Code</apex:outputPanel> </apex:facet> {!a.MailingPostalCode} </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >Phone</apex:outputPanel> </apex:facet> {!a.Phone} </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >Email</apex:outputPanel> </apex:facet> {!a.Email} </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:outputPanel> </apex:actionRegion> </apex:tab> <!-- NEW CONTACT TAB --> <apex:tab label="New Contact" name="tab2" id="tabTwo"> <apex:pageBlock id="newContact" title="New Contact" > <apex:pageBlockButtons > <apex:commandButton action="{!saveContact}" value="Save & Close"/> </apex:pageBlockButtons> <apex:pageMessages /> <apex:pageBlockSection columns="2"> <apex:inputField value="{!Contact.FirstName}"/> <apex:inputField value="{!Contact.LastName}"/> <apex:inputField value="{!Contact.AccountId}"/> <apex:inputField value="{!Contact.MailingStreet}"/> <apex:inputField value="{!Contact.MailingCity}"/> <apex:inputField value="{!Contact.MailingState}"/> <apex:inputField value="{!Contact.MailingPostalCode}"/> <apex:inputField value="{!Contact.MailingCountry}"/> <apex:inputField value="{!Contact.Phone}"/> <apex:inputField value="{!Contact.Email}"/> </apex:pageBlockSection> </apex:pageBlock> <script> if({!Contact.id!=null}){ //alert('{!Contact.Name} {!Contact.id}'); top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!Contact.Id}','{!JSENCODE(Contact.Name)}', false);self.close(); } </script> <script> var overwriteObj3="001"; var overwriteObjConf="Account"; var overwriteObjC="003"; var overwriteObjConfC="Contact"; function getParameterByName( name ,url){ name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( url ); if( results == null ) return ""; else return decodeURIComponent(results[1].replace(/\+/g, " ")); } var lookupPickOrig=null; $(document).ready(function(){ $("body").bind("OnRenderDone",function(){ if(lookupPickOrig==null){ lookupPickOrig= openLookup;//save old function if needed } openLookup=function(a, b,c, d,e,f,g,l){//overwrite with your custom code //alert(a+"~"+b+"~"+c+"~"+d+"~"+e+"~"+f+"~"+g+"~"+l); var ax=a; if(ax.indexOf("lktp=001”)>-1){ var lknm=getParameterByName("lknm",ax); var lkfm=getParameterByName("lkfm",ax); var lksrch=getParameterByName("lksrch",ax); //alert(b+"~"+c+"~"+d+"~"+e+"~"+f+"~"+g+"~"+l); ax="/apex/AccountLookupControl?"+(ax.split("?")[1]+"&frm="+escape(lkfm)+"&txt="+escape(lknm)+d); // lookupPickOrig(ax, b,c, d,e,f,g,l); window.open(ax,"_blank","width=690,height=690"); }else{ lookupPickOrig(ax, b,c, d,e,f,g,l); } //put your code here } }); }); </script> </apex:tab> </apex:tabPanel> </apex:outputPanel> </apex:form> </apex:page>
The Script that should open the custom popup and bypass the standard Salesforce account lookup dialog
<script> var overwriteObj3="001"; var overwriteObjConf="Account"; var overwriteObjC="003"; var overwriteObjConfC="Contact"; function getParameterByName( name ,url){ name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( url ); if( results == null ) return ""; else return decodeURIComponent(results[1].replace(/\+/g, " ")); } var lookupPickOrig=null; $(document).ready(function(){ $("body").bind("OnRenderDone",function(){ if(lookupPickOrig==null){ lookupPickOrig= openLookup;//save old function if needed } openLookup=function(a, b,c, d,e,f,g,l){//overwrite with your custom code //alert(a+"~"+b+"~"+c+"~"+d+"~"+e+"~"+f+"~"+g+"~"+l); var ax=a; if(ax.indexOf("lktp=001”)>-1){ var lknm=getParameterByName("lknm",ax); var lkfm=getParameterByName("lkfm",ax); var lksrch=getParameterByName("lksrch",ax); //alert(b+"~"+c+"~"+d+"~"+e+"~"+f+"~"+g+"~"+l); ax="/apex/AccountLookupControl?"+(ax.split("?")[1]+"&frm="+escape(lkfm)+"&txt="+escape(lknm)+d); // lookupPickOrig(ax, b,c, d,e,f,g,l); window.open(ax,"_blank","width=690,height=690"); }else{ lookupPickOrig(ax, b,c, d,e,f,g,l); } //put your code here } }); }); </script>

did you call this page somewhere? You can edit ur custom buttons to display this page when a user wants to search.