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
anil.ax822anil.ax822 

inputtext field as lookup field using visualforce page for custom object fields

Hi,

i have an custom object Position__c ,in this i have a field called
PositionName,
i want to show this textfield in Visualforce page as text box with
lookup field attached.

Please provide some code

Regards,

ANI


kiranmutturukiranmutturu

try this

 


<apex:page><apex:form>    <apex:inputText />    <a href="#" id="link" title="Contact Lookup (New Window)" tabindex="6"  onclick="javascript&colon;window.open('https://ap1.salesforce.com/_ui/common/data/LookupPage?lkfm=editPage&lknm=newOwn&lktp=StandardUserLoo..."><img class="lookupIcon" title="Contact Lookup (New Window)" alt="Contact Lookup (New Window)" src="/s.gif"/></a></apex:form>  </apex:page>

shra1_devshra1_dev

Hi Anil,

 

May I know why you are not using the Standard Controller and inputField to display the lookup field?

 

 

Regards,

Shravan

anil.ax822anil.ax822

Hi

 

i did the same,but here position1_c object contains 2 record types ,is it true that record type play role in lookup field ???

 

and plz look at this code

here position is the field i need  to display lookup field

 

<apex:page standardController="Position1__c" extensions="Jobapp">
<apex:form >
<apex:pageBlock title="New Job Application">
<apex:pageBlockButtons >
  <apex:commandButton action="{!Save}" value="Save"/>
   <apex:commandButton action="{!Savenew}" value="Save&New"/>
    <apex:commandButton action="{!Cancel}" value="Cancel"/>
    </apex:pageBlockButtons>
<apex:pageBlockSection title="Information">
<apex:pageBlockSectionItem >
<apex:outputLabel >Candidate:</apex:outputLabel>
<apex:inputText value="{!cand}"/></apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Position:</apex:outputLabel>
<apex:inputField value="{!Position1__c.name}"/></apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Cover Letter:</apex:outputLabel>
<apex:inputTextarea cols="10"  rows="2"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
Status:<apex:selectList value="{!stat}" multiselect="false" size="1">
<apex:selectOptions value="{!status}" ></apex:selectOptions>
</apex:selectList>
 </apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form> 
</apex:page>

 

shra1_devshra1_dev

Hi Anil,

 

I donno wat you are trying to do, You are using Standard controller as "Position1__c" and you want to select a position from there.

 

Do you have a self lookup field on that object? If not first create it.

 

then you can use that Field API name in the Input field.

 

<apex:InputField value="{!Position1__c.SelfLookUpfieldAPIName}"/>  you get the lookup functionality by default.

 

Regarding record Type dependency I hope it may, if you have related lookup filters with the record type criteria.

 

 

Regards,

Shravan

anil.ax822anil.ax822

Hi shravan,

 

yes i have a lookup field called JobPosition__c as u said i tried

 

<apex:inputField Value="{!Position__c.JobPosition__c}" />

 

But it shows error.

 

do i need to write apex code for this in controller ,if yes plz give me some code for that

 

Thanks

 

 

anil.ax822anil.ax822

yeh shravan i got it

 

thanks it works fine

 

THanku very much

 

 

Pooja Lahoti 10Pooja Lahoti 10
i have student__c as custom object and i want student name in vf page as lookup field plz send me code