You need to sign in to do that
Don't have an account?
indyinfy
Message Edited by Tran Man on 02-21-2008 10:48 AM
How to add a Look Up field in VF page
I have a VF page whose standard controller is Contact . I have 3 fields First name, last name and Account Name. On click of Save I should be able to add a Contact with these 3 values. But how to add Account in the page which has to be a lookup field. Please help
Code:
<apex:page standardController="Contact"> <apex:Form> <apex:pageBlock>Create New Contact</apex:pageBlock> <p>First name: <apex:inputField value="{!contact.FirstName}"/></p> <p>Last name: <apex:inputField value="{!contact.LastName}"/></p> <p>Account Name: <apex:inputField value="{!contact.accountid}"/></p> <apex:commandButton action="{!save}" value="Save"/> </apex:Form> </apex:page>
Message Edited by Tran Man on 02-21-2008 10:48 AM
On save the contact is created.
Is your browser blocking popups?
Thnx for the response Manu. But the same code does not work for me. The page it self does not show up. it gives an error on click of Save.
Manu,
One thing I noticed. I directly copied the URL of the VF page and it worked fine.
But what I was trying to do earlier is I have overridden standard button "New" in Contact object and selected this VF page. Then it is not working.
But does not display if you override the 'New' button?
Are you able to select your page when attempting to override the 'New' button? i.e., successfully override the button
Message Edited by manu on 02-05-2008 03:20 PM
You've hit a bug that we discovered about a week ago. A page with an inputField lookup will work fine when accessed directly, but when used as a "New" override, it does not work.
This has been fixed and should be patched this weekend. Apologies for the inconvenience.
Please let us know if you're still seeing this issue on Monday.
Thanks,
Jill
Hi, it looks like this problem still exists: (in the following, LOA approval is on the detail side of a master-detail relationship to Opportunity)
when I access the VF page directly the inputfield is ok:
But after I click "quicksave", the field becomes read-only:
I also used this VF page to override the "New" and "edit" button, when user click "edit" button to edit an existing record, the field is also read-only:
Is this supposed to be the way it should work?
If I change to the following, I got an error:
<apex:inputField value="{!LOA_Approval__c.OpportunityId}" /> Error: Could not resolve field 'OpportunityId' from <apex:inputField> value binding '{!LOA_Approval__c.OpportunityId}'