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
ManzaManza 

Business and Personal Accounts look up

I am trying to add a look up to accounts in a visualforce page, however this look up only display business accounts, and I need to display both (Business and personal Accounts).

PAGE:
<apex:page controller="MyController" sidebar="false" showHeader="false">
    <apex:form >
  <apex:inputField value="{!referrer.Parentid}" />
    </apex:form>
</apex:page>
CONTROLLER:

public with sharing class MyController {

    public Account referrer{get;set;}
   
    public MyController() {
        referrer = new Account();       
    }

}

On this post (https://success.salesforce.com/answers?id=90630000000hq1AAAQ)
they mention that changing the param in the url of &cnpa=0 to &cnpa=1, so I guess there must be a set up somewhere in salesforce to change this value?
Best Answer chosen by Manza
ManzaManza
Hi David
yeah the problem of that is that we have more than 50k records, so that wouldnt work. I was able to amke it work adding a javascript and modifying this way the url of the pop up window. 
from 
https://fabian-jdlsoft.cs6.force.com/maincom/_ui/common/data/LookupPage?lkfm=j_id0%3Aj_id55&lknm=j_id0%3Aj_id55%3Aj_id57%3Aj_id74%3Aj_id75%3Aj_id77&cnpa=0&lktp=001&lksrch=
to 
https://fabian-jdlsoft.cs6.force.com/maincom/_ui/common/data/LookupPage?lkfm=j_id0%3Aj_id55&lknm=j_id0%3Aj_id55%3Aj_id57%3Aj_id74%3Aj_id75%3Aj_id77&cnpa=1&lktp=001&lksrch=

so cnpa=0 to cnpa=1

my javascript is:
function init() {
    //alert ("running");
    var src;
    var links = document.getElementsByTagName("a");
    for(var i=0; i<links.length; i++) {
        if(links[i].getAttribute("title") == "Parent Client Lookup (New Window)"){
            src = links[i].href;
            src = src.replace("cnpa%3D0","cnpa%3D1");
        links[i].href = src;
            //modify value of cnpa to 1
        }
      //console.log(src);
    }  
}
window.onload = init;

However i am not very happy of using this solution as if something change on salesforce the new url might not work

I am quite surprice that there is no param somewere were we can set up this value to be 1

All Answers

David "w00t!" LiuDavid "w00t!" Liu
According to this, the standard ParentId field does not support Person Accounts:
https://help.salesforce.com/HTViewHelpDoc?id=account_person_behavior.htm&language=en_US

You could certainly create your own custom lookup that supported them though, but I don't know if that's an option for you!
ManzaManza
Hi David
yeah the problem of that is that we have more than 50k records, so that wouldnt work. I was able to amke it work adding a javascript and modifying this way the url of the pop up window. 
from 
https://fabian-jdlsoft.cs6.force.com/maincom/_ui/common/data/LookupPage?lkfm=j_id0%3Aj_id55&lknm=j_id0%3Aj_id55%3Aj_id57%3Aj_id74%3Aj_id75%3Aj_id77&cnpa=0&lktp=001&lksrch=
to 
https://fabian-jdlsoft.cs6.force.com/maincom/_ui/common/data/LookupPage?lkfm=j_id0%3Aj_id55&lknm=j_id0%3Aj_id55%3Aj_id57%3Aj_id74%3Aj_id75%3Aj_id77&cnpa=1&lktp=001&lksrch=

so cnpa=0 to cnpa=1

my javascript is:
function init() {
    //alert ("running");
    var src;
    var links = document.getElementsByTagName("a");
    for(var i=0; i<links.length; i++) {
        if(links[i].getAttribute("title") == "Parent Client Lookup (New Window)"){
            src = links[i].href;
            src = src.replace("cnpa%3D0","cnpa%3D1");
        links[i].href = src;
            //modify value of cnpa to 1
        }
      //console.log(src);
    }  
}
window.onload = init;

However i am not very happy of using this solution as if something change on salesforce the new url might not work

I am quite surprice that there is no param somewere were we can set up this value to be 1
This was selected as the best answer