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
BryanTSCBryanTSC 

Account Lookup Field Authentication

I have a visualforce page with a custom controller hosted on Sites.  The page creates a contact record and several other custom object records simultaneously.  In order to link the contact to an account, I have added the Account Lookup field from the contact object.

 

I have set the guest user profile to allow Read permissions on Accounts and also checked the field level security.  Everything looks okay, but when I go out onto the Site and attempt to use the lookup it complains about authentication.  Is it possible to get around this or is there another method I should be considering?

Best Answer chosen by Admin (Salesforce Developers) 
BryanTSCBryanTSC

I did not have lookups enabled for my site, once I set this up in the "Public Access Settings" everything functioned as expected.

All Answers

CaptainObviousCaptainObvious

I too experienced this when working on a Sites project. Apparently, lookup fields require the user to be authenticated (this requires a license). For various reasons, we chose not to authenticate users.

 

I ended up creating a dynamic picklist in the controller based on the related object (Program_Codes__c) and binding it to the lookup field on the VF page (Program__c).

 

Controller:

 

    public List<SelectOption> getItems(){
        List<SelectOption> options = new List<SelectOption>();
        List<Program_Codes__c> programList = [Select Id, Name FROM Program_Codes__c ];
        options.add(new SelectOption('--None--','--None--'));
        for (Integer j=0;j<programList.size();j++)  {
            options.add(new SelectOption(programList[j].Id,programList[j].Name));
        }
        return options;
    }

 

VF Page:

 

    <apex:column headerValue="Program">
        <apex:selectList value="{!a.Program__c}" multiselect="false" size="1" style="font-size:.95em;">
            <apex:selectOptions value="{!items}" id="a"/>
        </apex:selectList>
    </apex:column>

 

 

BryanTSCBryanTSC

Hmm . . . darn it.

 

This WOULD work if we didn't have so many accounts.

 

If the user just enters some text into the lookup field and hits save, it does save if it finds a match or prompts the user to select among multiple possible matches.  I wonder if I could hide the magnifying glass somehow so that users aren't inclined to click on it.


Are you/anybody aware of that as a possibility?

CaptainObviousCaptainObvious

Hehe, that could pose a problem! Could you add criteria to the query so that you only retrieve certain accounts? In my case, the object is pretty much set in size, and only serves as a lookup table.

 

As to hiding the magnifying glass, try adding the following css to your VF page:

 

 

<style>

.lookupIcon { display:none; } 

</style>

 

 

BryanTSCBryanTSC

I did not have lookups enabled for my site, once I set this up in the "Public Access Settings" everything functioned as expected.

This was selected as the best answer
s5s5

Hi,

 

Even i am facing the same problem like you.I enabled all field level security and profile permission also but still in public site if i opened this lookup it is just opening and it is not showing any data.

 

Please let me know how you to enable the lookup in public site so as to retrieve the data from Account.

Thanks in advance.