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
AnnaTAnnaT 

Lookup button on inputfield is not displayed

I'm creating editable table.

When I create lookup field, lookup button is not displayed.

 

My code is this.

 

 

<apex:page standardStylesheets="true" showHeader="True" sidebar="false" standardController="CR_CO__c" recordSetVar="crco"  > 
<style>
        .headerStyle{background-color:#0099FF;color:#000000}
        .dateStyle{width:250px}
</style>
<apex:form >
<apex:commandButton action="{!save}" value="Save" id="theButton"/>
<body>
<table border="2" >
<td><apex:inputField value="{!cro.Location__r.Name}"  />
</td>

</tr>
</apex:repeat>
</table>
</body>
</apex:form>
</apex:page>

 

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You wouldn't specify a lookup field this way:

 

<apex:inputField value="{!cro.Location__r.Name}" />

 

as that allows the user to overwrite the name on the related record.

 

Instead, use the following, which will allow you to overwrite the relationship field:

 

<apex:inputField value="{!cro.Location__c}" />

All Answers

Chamil MadusankaChamil Madusanka

Hi,

 

Use correct lookup field API name. Check your object and it's lookup field. replace the inputField value with that lookup field API name.

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

 

Chamil's Blog

bob_buzzardbob_buzzard

You wouldn't specify a lookup field this way:

 

<apex:inputField value="{!cro.Location__r.Name}" />

 

as that allows the user to overwrite the name on the related record.

 

Instead, use the following, which will allow you to overwrite the relationship field:

 

<apex:inputField value="{!cro.Location__c}" />
This was selected as the best answer
AnnaTAnnaT

Thank you for your help!!

I could create lookup button.

 

Thank you so much!!!

 

Anna

ECoronaECorona

I tried your example, but the field is only shown on the preview of the page, running the site the field is missing

bob_buzzardbob_buzzard

Is the lookup field exposed to the guest site user profile?

ECoronaECorona

I think yes, the field is visible for all my users, is there a way to verify?

 

Thank you Bob!

bob_buzzardbob_buzzard

If this is an unauthenticated site, you can check via the public access settings button on the site detail.

 

The profile will also need read access to the sobject that the lookup points to.

ECoronaECorona

The profile have access to Lead, contacts, api, search phrase and new object, access to vf pages and access to the standar search pages i don't know what could be missing.

 

In the preview of the page i can see the lookup field but when i access to the site... is not there! 

bob_buzzardbob_buzzard

Have you checked the field level security, not just the object level?

ECoronaECorona
Yes is visible and editable for all my users :(