You need to sign in to do that
Don't have an account?
Rahul Sharma
Best way to display a lookup field?
Hello board,
I would like to know whats the best way to display an input lookup field in a custom page.
I know if we want to show a account lookup, we can do it by using a contact object in controller and use objContact.AccountId as a input field in a page.
Thats works in case of lookup but in case of master detail it shows a outputfield if we try to prepopulate a master object.
Any ideas?
In that example too its lookup relationship between Account and contact.
Thanks anyways.
Outputfield is displayed due to the fact that master cant be changed for a detail record once selected.
So, Its the standard way and it wont allow to change a master once prepopulated.
All Answers
How you are prepopulating the field???
Hi Umesh,
I took a object instance of the detail which has reference of Master object in the controller.
And in constructor i assigned the object instance with record.
Now to show the lookup selector in Custom vf page i'm using a Input field binded with DetailObjectInstance.ParentReferencefield.
But it works/ it allow to select any master for the case when i dont prepopulate. but if i try to prepopulate its shown in outputField instead of input.
That may be due to the fact that Master once selected can't be changed, Is there any work around for this?
As a workaround Custom Lookup page may help you..
http://blog.jeffdouglas.com/2011/08/12/roll-your-own-salesforce-lookup-popup-window/
In that example too its lookup relationship between Account and contact.
Thanks anyways.
Outputfield is displayed due to the fact that master cant be changed for a detail record once selected.
So, Its the standard way and it wont allow to change a master once prepopulated.
Yeah thats a limitation of master-detail relationship..