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
Harald KloseHarald Klose 

How can I display a Lookup to Accounts in a ListProperty

Hello,

I have a Wrapper for a PageList. In this Wrapper there is a field called Versandpartner which is of type Account. In the VF page I cannot display the field {!lp.Versandpartner}, because then the system tells me "could not resolve the entity from apex inputfield value binding". I can display the field {!lp.Versandpartner.Name} but then it is only a pure text field and does not have the Metadata binding to Accounts. I could enter any string and don't have the magnifying glass. 
My wrapper looks like this:
public with sharing class BarVerkaufLieferPosWrapper {

    public Lieferscheinposition__c LieferPos {get; set;}  // the record being wrapped around
    public Integer LieflfdNr {get; set;}
    public string  stornostatus {get; set;}
    public Integer Lieferscheinnr {get; set;}
public string statisticTable = null;
public Account Versandpartner {get; set;}
public Lager__c Lager {get; set;}
public string Paragraph300_302 = null;

    // constructor for NEW Artikel records
    public BarVerkaufLieferPosWrapper(){
  LieflfdNr = 0;
  stornostatus = '';
        LieferPos = new Lieferscheinposition__c();
     Lieferscheinnr = 1;
  statisticTable = '<table><tr><td width=200>&nbsp;</td></tr></table>';
  Versandpartner = null;
  Lager = null;
  Paragraph300_302 = '300';
    }
   
    // constructor used for existing Arikel records
    public BarVerkaufLieferPosWrapper(Lieferscheinposition__c LP){
  LiefLfdNr = 0;
  stornostatus = '';
        Lieferpos = LP;
     Lieferscheinnr = 1;
   statisticTable = '<table border=1><tr><td width=200>&nbsp;</td></tr></table>';
  Versandpartner= null;
  Lager = null;
  Paragraph300_302 = '300';
    }
public string getStatisticTable () {
  return statisticTable;
}
}

and the lines in the VF Page:
<apex:column headerValue="Versandpartner">
                 <apex:actionregion immediate="True">
                  <apex:inputfield value="{!LP.Versandpartner.Name}">
                   <apex:actionsupport action="{!changedVersandpartner}" event="onchange" rerender="tabpanel,geliefert,Bedarfe,BedarfBlock,Page-Messages">
                  <apex:param name="VsPart" assignto="{!applyLiPoslfdNr}" value="{!LP.LieflfdNr}"/>
                  </apex:actionsupport>
                  </apex:inputfield>
                </apex:actionregion>
              </apex:column>

How can I change the behaviour, that this looks like a normal lookup for accounts?

Thanks in advance
Harald
bob_buzzardbob_buzzard
Lookups work on ids, not the name of the record.  If you change your inputfield to the id of the account that should work I think:

<apex:inputfield value="{!LP.Versandpartner.Id}">

of course this does mean that if you want the account name you'll have to retrieve that yourself - I wrote a blog post a while back on this at:

http://bobbuzzard.blogspot.co.uk/2011/11/retrieve-related-object-fields.html