<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>joe-ferraro.com &#187; picklist</title>
	<atom:link href="http://joe-ferraro.com/tag/picklist/feed/" rel="self" type="application/rss+xml" />
	<link>http://joe-ferraro.com</link>
	<description>adless since 2008</description>
	<lastBuildDate>Wed, 25 Aug 2010 15:49:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>lookup &#8211;&gt; picklist</title>
		<link>http://joe-ferraro.com/2009/06/lookup-picklist/</link>
		<comments>http://joe-ferraro.com/2009/06/lookup-picklist/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 19:47:14 +0000</pubDate>
		<dc:creator>joe</dc:creator>
				<category><![CDATA[apex]]></category>
		<category><![CDATA[salesforce]]></category>
		<category><![CDATA[visualforce]]></category>
		<category><![CDATA[lookup relationship]]></category>
		<category><![CDATA[picklist]]></category>

		<guid isPermaLink="false">http://joe-ferraro.com/?p=67</guid>
		<description><![CDATA[I've had several clients "voice concerns" about Salesforce.com's lookup functionality relative to user acceptance. Well, if you're dealing with a relatively simple lookup table, you can override an object's new/edit page with a Visualforce page and display the lookup field to the user as a picklist.]]></description>
			<content:encoded><![CDATA[<div style="padding: 5px; margin-bottom: 10px;"><img src="http://joe-ferraro.com/images/lookupToPicklist.png" alt="" /></div>
<p>I&#8217;ve had several clients &#8220;voice concerns&#8221; about Salesforce.com&#8217;s lookup functionality relative to user acceptance.  Well, if you&#8217;re dealing with a relatively simple lookup table, you can override an object&#8217;s new/edit page with a Visualforce page and display the lookup field to the user as a picklist.</p>
<p>In the [live Visualforce] example below, the user is creating a new &#8220;Some_Object__c&#8221; record.  The Some_Object__c object is very simple: it&#8217;s comprised of a standard name field and a custom lookup to another table called &#8220;Location__c&#8221;.  Location__c is comprised of name, city, and state fields and there are only 8 rows in the table.  Rather than having the user click the magnifying glass icon to lookup to the Location__c table, one can quite easily display a list of possible values to the user along with any other pertinent information (in this case, I&#8217;m displaying Location__c&#8217;s City__c and State__c fields as well).</p>
<div style="margin-top: 60px;">
 <IFRAME src="https://crmmanager-developer-edition.na6.force.com/test/NewObject" height="300" width="650" frameborder="0" scrolling="no" ></IFRAME>
</div>
<pre name="code" class="java">

public class SomeObjectExtension {
	private final ApexPages.standardController controller;
	private final Some_Object__c obj;

	public SomeObjectExtension(ApexPages.StandardController stdController) {
		this.controller = stdController;
		this.obj = (Some_Object__c)stdController.getRecord();
	}

	public SelectOption[] getLocationOptions() {
		SelectOption[] locations = new SelectOption[]{};
		locations.add(new SelectOption(&#039;&#039;,&#039;--None--&#039;));
		for (Location__c l : [select id, name, city__c, state__c from location__c where isdeleted = false order by name]) {
			locations.add(new SelectOption(l.id, l.name + &#039; (&#039; + l.city__c + &#039;, &#039; + l.state__c + &#039;)&#039;));
		}
		return locations;
	}
}
</pre>
<pre name="code" class="java">

&lt;apex:page standardController=&quot;Some_Object__c&quot; extensions=&quot;SomeObjectExtension&quot; showHeader=&quot;false&quot; &gt;
&lt;apex:sectionHeader title=&quot;Some Object Edit&quot; subtitle=&quot;New Some Object&quot; /&gt;
&lt;apex:form id=&quot;someObjectForm&quot;&gt;
&lt;apex:pageBlock title=&quot;Some Object Edit&quot; mode=&quot;edit&quot;&gt;
&lt;apex:pageBlockButtons &gt;
&lt;apex:commandButton action=&quot;{!save}&quot; value=&quot;Save&quot;/&gt;
&lt;/apex:pageBlockButtons&gt;
&lt;apex:pageBlockSection title=&quot;Some Object Information&quot; columns=&quot;1&quot;&gt;
&lt;apex:inputField value=&quot;{!Some_Object__c.Name}&quot; required=&quot;true&quot;/&gt;
&lt;apex:pageBlockSectionItem &gt;
&lt;apex:outputLabel value=&quot;{!$ObjectType.Some_Object__c.fields.Location__c.label}&quot; for=&quot;pLabel&quot;/&gt;
&lt;apex:outputPanel styleClass=&quot;requiredInput&quot; layout=&quot;block&quot;&gt;
&lt;apex:outputPanel styleClass=&quot;requiredBlock&quot; layout=&quot;block&quot;/&gt;
&lt;apex:actionRegion &gt;
&lt;apex:selectList id=&quot;locationLookupPicklist&quot; value=&quot;{!Some_Object__c.Location__c}&quot; size=&quot;1&quot; rendered=&quot;true&quot;&gt;
&lt;apex:selectOptions value=&quot;{!locationOptions}&quot;/&gt;
&lt;/apex:selectList&gt;
&lt;/apex:actionRegion&gt;
&lt;/apex:outputPanel&gt;
&lt;/apex:pageBlockSectionItem&gt;
&lt;/apex:pageBlockSection&gt;
&lt;/apex:pageBlock&gt;
&lt;/apex:form&gt;
&lt;/apex:page&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://joe-ferraro.com/2009/06/lookup-picklist/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
