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
Manu ErwinManu Erwin 

Is it possible to bind apex:inputField as a Lookup if no metadata Lookup field exists?

I have a VF page that displays a result set of "ObjectA" records based on various filter criteria.

I need to associate these records to an "ObjectB" record however the "ObjectB" record does NOT have any other object referencing it within my org (i.e., there are no 'Lookup' fields to ObjectB anywhere).

 

I do NOT want to pollute my real objects (i.e., ones that contain data) with a Lookup to ObjectB just to get my VF page to work so my workaround has been to create a 'Utility Object' which does have a Lookup to ObjectB.  Then all I need to do is instantiate a Utility__c record and make use of the lookup to bind my apex:inputField to.

 

It would be great however if there was a way to create this on the fly in my controller to be bound to.

 

I know I 'could' rebuild the lookup functionality OR I 'could' make the selection of the ObjectB record be part of a multistep wizard however I'd prefer to make use of the standard Lookup functionality as bound to the apex:inputField tag AND not need a Utility Object.

 

Suggestions?

Best Answer chosen by Admin (Salesforce Developers) 
Chamil MadusankaChamil Madusanka

Hi,

 

I think you can get help from following link.

 

http://bobbuzzard.blogspot.com/2010/09/visualforce-lookup.html

 

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.

All Answers

Chamil MadusankaChamil Madusanka

Hi,

 

I think you can get help from following link.

 

http://bobbuzzard.blogspot.com/2010/09/visualforce-lookup.html

 

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.

This was selected as the best answer
Manu ErwinManu Erwin

Thanks chamil for the link to bob buzzards coded solution for this - I've seen things like this in the past and this is exactly what I'm trying to not have to do due to the amount of coding required.

 

Appreciate the response though :)