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

inputField w/ Lookup functionality while using custom controller



I am trying to create a lookup field without using a standardController.  


Inside my VF Page I have the following:



<apex:inputField id="acctField" value="{!acct.Id}" />


Inside my custom controller I have the following:



... Account acct; ... public Account getAcct() {return acct;} public void setAccount(Account acct) {this.acct = acct;}


 But I get an error:

Unable to Access Page Invalid parameter value "" for parameter "id". Error: The value of the parameter specified above contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and re-submit. If the error still persists, please report it to our Customer Support team and provide the URL of the page you were requesting as well as any other related information.




Any ideas?




I have always used "phantom" records when I need the inputField to be a lookup but I'm actually not creating the type of record that the phantom is using (i.e. so I can get some account information, etc).

For example, one might do this:


<!-- page fragment --> <apex:inputField value="{!opp.account}"/> // Controller example public class theControl { public opportunity opp { get; set; } public theControl() { opp = new opportunity(); } public void doSomething() { if(opp.account) // The user has selected a record... } }







I just posted an example that is pretty much exactly what you have shown here but it gives some weird error on the lookup when you click any button in the form:


The only difference (which is why I started a new thread) might be the key, and that is that I am using a standard controller, then extending it to define my "phantom" of a DIFFERENT object type than the standard controller.  You would think that would be ok, but I have a feeling there is some catch with the lookup fields and how they interact with extended standard controllers versus custom.  I appreciate if you can give any advice on how to get my very elementary example to work.