<?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>X-Squared On-Demand &#187; Development</title>
	<atom:link href="http://www.x2od.com/cat/salesforce/development/feed" rel="self" type="application/rss+xml" />
	<link>http://www.x2od.com</link>
	<description>Salesforce Configuration, Administration, and Development</description>
	<lastBuildDate>Fri, 11 Jun 2010 16:30:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Sophisticated DateTime &#8220;Formula Fields&#8221; with Apex and Field-Level Security</title>
		<link>http://www.x2od.com/2010/05/17/sophisticated-datetime-formula-fields-with-apex-and-fls.html</link>
		<comments>http://www.x2od.com/2010/05/17/sophisticated-datetime-formula-fields-with-apex-and-fls.html#comments</comments>
		<pubDate>Mon, 17 May 2010 20:39:25 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Force.com Platform]]></category>
		<category><![CDATA[Native Application]]></category>
		<category><![CDATA[Salesforce CRM]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[salesforce.com]]></category>
		<category><![CDATA[Eclipse IDE]]></category>
		<category><![CDATA[Force.com Builder]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=997</guid>
		<description><![CDATA[What do you do when you want to calculate a formula-like field but a regular formula won't work? Salesforce CRM's formulas handle dates very well. If you want to enter a date value and have formula fields display, for instance, mydate__c + 21 days, that's simple. Just use mydate__c + 21. Side note: If you [...]]]></description>
			<content:encoded><![CDATA[<p>What do you do when you want to calculate a formula-like field but a regular formula won't work?  </p>
<p>Salesforce CRM's formulas handle dates very well.  If you want to enter a date value and have formula fields display, for instance, mydate__c + 21 days, that's simple.  Just use <code> mydate__c + 21</code>.</p>
<p><i>Side note: If you try going the long way around and use <code>DATE( YEAR( mydate__c ), MONTH( mydate__c ), DAY( mydate__c ) + 21 ) </code> and mydate__c = 09/17/2010, Salesforce returns #Error! because there's no date 09/38/2010.  Similarly, adding three months to a date like 1/31/2010 will also give an error.  More about this in a future post.</i></p>
<p>DateTime fields are like Date fields, but they include... wait for it... a time component (and can be created in the running user's local time zone or in GMT).</p>
<p>Here's a use-case for a DateTime formula field:</p>
<p>A photography studio schedules photo shoots, and different packages include different durations.  Similarly, we could use a hair salon which offers different services, each with a different duration, a dentist... you get the idea.</p>
<p>Requirements:</p>
<ol>
	<li>Enter a DateTime for an appointment start time (<code>starttime__c</code>)</li>
	<li>Enter a duration (though in a production system, I'd include a value on the <code>Product2</code> sObject, we'll just enter a value here) (<code>minutes__c</code>)</li>
	<li>Display a read-only DateTime field with the end time (<code>endtime__c</code>)</li>
	<li>The end time must be read-only to all users, like any formula field</li>
</ol>
<p>Here's what won't work:</p>
<ul>
	<li>A formula field won't work because there are no MINUTE(), HOUR(), SECOND() formula functions</li>
	<li>Workflow won't work because it depends on formulas to fill new values for date/datetime fields</li>
</ul>
<p>That leaves Apex.  First, the configuration:</p>
<ol>
	<li>Create DateTime field <code>starttime__c</code></li>
	<li>Create DateTime field <code>endtime__c</code></li>
	<li>Set <code>endtime__c</code> field-level security to Read-Only for all profiles</li>
	<li>Create Number (18,0) field <code>minutes__c</code></li>
	<li>Create a trigger on the sobject</li>
</ol>
<p>Here's the trigger:</p>
<pre class="brush: java;">
trigger timeTrigger on TestObject__c (before insert, before update) {
    for (TestObject__c t : Trigger.New){
    	if(t.StartTime__c != null &amp;&amp; t.minutes__c != null){
        datetime myDateT = t.StartTime__c;
        double d = t.minutes__c;
        Integer shootmins = d.intValue();
        if(mydateT != null &amp;&amp; shootmins != null)
        	t.EndTime__c = myDateT.addminutes(integer.valueof(shootmins));
       	}
    }
} 
</pre>
<p>Regular readers will note that I do usually split triggers into a trigger and a class, but I've not done so here purely for the sake of brevity.</p>
<p>Here's the test code:</p>
<pre class="brush: java;">
public without sharing class shootTimesTriggerTest {

    private static testMethod void ShootCalculateEndTime_PositiveTestCases() {
        TestObject__c to;
        TestObject__c l;    
        test.starttest();
        l = new TestObject__c (name = 'test');
        datetime myDateTime = datetime.newInstance(2008, 12, 1, 12, 30, 2);
        l.StartTime__c = myDateTime;
        l.minutes__c = 90;
        insert l;
        to = [SELECT id, EndTime__c FROM TestObject__c WHERE id = :l.id];
        datetime newDateTime = datetime.newInstance(2008, 12, 1, 14, 0, 2);
        system.assertequals(to.EndTime__c, newDateTime);
        l.minutes__c = 45;
        update l;        
        to = [SELECT id, EndTime__c FROM TestObject__c WHERE id = :l.id];
        newDateTime = datetime.newInstance(2008, 12, 1, 13, 15, 2);
        system.assertequals(to.EndTime__c, newDateTime);
        test.stoptest();
    }

    private static testMethod void OppCalculateEndTime_NegativeTestCases() {
        test.starttest();
        TestObject__c l = new TestObject__c (name = 'test');
        l.minutes__c = null;
        insert l;
        system.assertequals(l.EndTime__c, null);
        test.stoptest();
    } 
}
</pre>
<p>A few points about how this works:</p>
<ul>
	<li>Triggers run in System mode, so they don't respect field-level security.  Thus, we can set a field to read-only for all profiles, and the EndTime__c field will still be updated.</li>
	<li>The test code runs in System mode as well, avoiding any potential problems if the field were set to invisible to a profile and we used System.RunAs() to test for various profiles.</li>
	<li>Although I'm not a fan of using SOQL queries this often, I used these in the interest of saving time.  Keep in mind that if you had quite a few queries in your regular code, adding these two might put you over the limit, so use queries sparingly!</li>
	<li>This is the only way I know of to add minutes to a DateTime.</li>
</ul>
<p>Did I miss anything?  Please let me know in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2010/05/17/sophisticated-datetime-formula-fields-with-apex-and-fls.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Computer Associates Plans To Release Agile Development Tool On Force.com Platform</title>
		<link>http://www.x2od.com/2009/11/19/computer-associates-planned-dev-tool.html</link>
		<comments>http://www.x2od.com/2009/11/19/computer-associates-planned-dev-tool.html#comments</comments>
		<pubDate>Thu, 19 Nov 2009 18:48:25 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Partners]]></category>
		<category><![CDATA[Force.com Platform]]></category>
		<category><![CDATA[New Features]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=859</guid>
		<description><![CDATA[Today, at Dreamforce 2009, Computer Associates plans to release CA Agile Planner (http://www.ca.com/agile), a tool to manage agile development teams. ]]></description>
			<content:encoded><![CDATA[<p>Today, at Dreamforce 2009, Computer Associates plans to release CA Agile Planner(<a href="http://www.ca.com/agile">http://www.ca.com/agile</a>), a tool to manage agile development teams.<br />
CA Agile Planner will be integrated with CA Clarity PPM (<a href="http://www.ca.com/ppm">http://www.ca.com/ppm</a>).</p>
<p>Although it was not clear how much of the demonstrated app will run on Force.com and how much will run on the CA servers (though it appeared to be 100% on Force.com), it was clear that the application was accessed via a force.com URL.</p>
<p>For more information, see <a href="http://www.ca.com/agile">http://www.ca.com/agile</a>.</p>
<p>A release date for the product was not mentioned, but the earliest planned release of any newly-announced feature thus far is Spring 2010, so one might assume that this will not be available until then.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2009/11/19/computer-associates-planned-dev-tool.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New Developer Library Released</title>
		<link>http://www.x2od.com/2009/11/19/new-developer-library-released.html</link>
		<comments>http://www.x2od.com/2009/11/19/new-developer-library-released.html#comments</comments>
		<pubDate>Thu, 19 Nov 2009 17:43:29 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Force.com Platform]]></category>
		<category><![CDATA[New Features]]></category>
		<category><![CDATA[Visualforce]]></category>
		<category><![CDATA[Winter 10]]></category>
		<category><![CDATA[salesforce.com]]></category>
		<category><![CDATA[Dreamforce 2009]]></category>
		<category><![CDATA[Salesforce.com]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=853</guid>
		<description><![CDATA[Today, Developer Force (http://developer.force.com) released its new library. Here are a few of them. All can be found at http://wiki.developerforce.com/index.php/Documentation. Workbook http://www.salesforce.com/us/developer/docs/workbook/index.htm Fundamentals http://www.salesforce.com/us/developer/docs/fundamentals/index.htm Cookbook http://www.salesforce.com/us/developer/docs/cookbook/index.htm Apex Advanced Code Example http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_shopping_cart_example.htm https://sites.secure.force.com/appexchange/listingDetail?listingId=a0N30000001saDCEAY And many more to come!]]></description>
			<content:encoded><![CDATA[<p>Today, Developer Force (<a href="http://developer.force.com">http://developer.force.com</a>) released its new library.  Here are a few of them.  All can be found at <a href="http://wiki.developerforce.com/index.php/Documentation">http://wiki.developerforce.com/index.php/Documentation</a>.</p>
<p>Workbook<br />
<a href="http://www.salesforce.com/us/developer/docs/workbook/index.htm">http://www.salesforce.com/us/developer/docs/workbook/index.htm</a></p>
<p>Fundamentals<br />
<a href="http://www.salesforce.com/us/developer/docs/fundamentals/index.htm">http://www.salesforce.com/us/developer/docs/fundamentals/index.htm</a></p>
<p>Cookbook<br />
<a href="http://www.salesforce.com/us/developer/docs/cookbook/index.htm">http://www.salesforce.com/us/developer/docs/cookbook/index.htm</a></p>
<p>Apex Advanced Code Example<br />
<a href="http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_shopping_cart_example.htm">http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_shopping_cart_example.htm</a><br />
<a href="https://sites.secure.force.com/appexchange/listingDetail?listingId=a0N30000001saDCEAY">https://sites.secure.force.com/appexchange/listingDetail?listingId=a0N30000001saDCEAY</a></p>
<p>And many more to come!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2009/11/19/new-developer-library-released.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Mention in the Developers Challenge</title>
		<link>http://www.x2od.com/2009/10/02/a-mention-in-the-developers-challenge.html</link>
		<comments>http://www.x2od.com/2009/10/02/a-mention-in-the-developers-challenge.html#comments</comments>
		<pubDate>Fri, 02 Oct 2009 19:56:51 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[X-Squared On Demand]]></category>
		<category><![CDATA[salesforce.com]]></category>
		<category><![CDATA[Apex]]></category>
		<category><![CDATA[Force.com Platform]]></category>
		<category><![CDATA[Sites]]></category>
		<category><![CDATA[Visualforce]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=754</guid>
		<description><![CDATA[The salesforce.com Developer Force Challenge has concluded, and the team of Force Squared and The Enforcer won a mention! Our Daily Shinro site was listed &#8220;for sheer exuberance!&#8221; I&#8217;m really proud of the site, though the lion&#8217;s share of the kudos go to John for the concept and site design. I just coded whatever he [...]]]></description>
			<content:encoded><![CDATA[<p>The salesforce.com <a href="http://blog.sforce.com/sforce/2009/09/developer-force-challenge-results.html">Developer Force Challenge has concluded</a>, and the team of Force Squared and The Enforcer won a mention!</p>
<p>Our <a href="http://www.dailyshinro.com">Daily Shinro</a> site was listed &#8220;for sheer exuberance!&#8221;  </p>
<p>I&#8217;m really proud of the site, though the lion&#8217;s share of the kudos go to John for the concept and site design.  I just coded whatever he told me to code; he&#8217;s the creative one!</p>
<p>So if anyone is looking for a custom Force.com Site or website integration to Salesforce, <a href="/contact">contact us</a> and let&#8217;s discuss your needs!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2009/10/02/a-mention-in-the-developers-challenge.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Overload Apex Class to be Controller AND Extension</title>
		<link>http://www.x2od.com/2009/07/24/overload-apex-class-to-be-controller-and-extension.html</link>
		<comments>http://www.x2od.com/2009/07/24/overload-apex-class-to-be-controller-and-extension.html#comments</comments>
		<pubDate>Fri, 24 Jul 2009 20:01:00 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Visualforce]]></category>
		<category><![CDATA[X-Squared On Demand]]></category>
		<category><![CDATA[Eclipse IDE]]></category>
		<category><![CDATA[Force.com Platform]]></category>
		<category><![CDATA[New Features]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=682</guid>
		<description><![CDATA[Coding the new premium version of Mass Update Contacts (details to come), I replaced the two parts of the page with Apex Components. This will allow the app to support custom address fields and international address formats.
I didn't want to write one ControllerExtension for the main page, a CustomController for the view section component, and another CustomController for the pageblocktable component. So here is the overloaded class constructor. Note that this works because an extension passes the StandardController to the constructor, and a CustomController passes nothing:]]></description>
			<content:encoded><![CDATA[<p>Wow - today brought an interesting discovery.  Here's the situation:</p>
<p>Coding the new premium version of Mass Update Contacts (details to come), I replaced the two parts of the page with Apex Components.  This will allow the app to support custom address fields and international address formats.</p>
<p>I didn't want to write one ControllerExtension for the main page, a CustomController for the view section component, and another CustomController for the pageblocktable component.  So here is the overloaded class constructor.  Note that this works because an extension passes the StandardController to the constructor, and a CustomController passes nothing:</p>

<pre class="brush: java;">
public with sharing class VersatileClass {

private Account account;

public VersatileClass(){
	system.debug('OPERATING AS CONTROLLER');
		if(System.currentPageReference().getParameters().get('id')==null){
			//Include error checking here
		} else{
			string AId = System.currentPageReference().getParameters().get('id');
			account = [select id, name from Account where id = :AId];
			//And whatever else you want to do
		}
}

public VersatileClass(ApexPages.StandardController controller) {
	system.debug('OPERATING AS EXTENSION');
		if(System.currentPageReference().getParameters().get('id')==null){
			//Include error checking here
		} else{
			this.account = (Account)controller.getRecord();
			//And whatever else you want to do
		}
	}
}
</pre>
<p>Enjoy!  This should save people a lot of time.</p>]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2009/07/24/overload-apex-class-to-be-controller-and-extension.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Email Inbox Version 2</title>
		<link>http://www.x2od.com/2009/07/15/email-inbox-version-2.html</link>
		<comments>http://www.x2od.com/2009/07/15/email-inbox-version-2.html#comments</comments>
		<pubDate>Thu, 16 Jul 2009 01:39:41 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Visualforce]]></category>
		<category><![CDATA[salesforce.com]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[X-Squared On Demand]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=664</guid>
		<description><![CDATA[Well, it took about ten minutes from the release of Email Inbox Version 1 for people to request additional features, screenshots, etc. Version 2 includes some neat icons, and this post has the multiple-times-requested screenshots we promised. First, a teaser screenshot. (There's a better one below the code.) Here's the updated Visualforce code: &#60;apex:page controller=&#34;EmailMessageController&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>Well, it took about ten minutes from the release of <a href="http://www.x2od.com/2009/07/14/visualforce-email-inbox.html">Email Inbox Version 1</a> for people to request additional features, screenshots, etc.  Version 2 includes some neat icons, and this post has the multiple-times-requested screenshots we promised.</p>
<p>First, a teaser screenshot.  (There's a better one below the code.)</p>
<center><a href="http://www.x2od.com/wp/uploads/EmailInbox-screenshot.JPG"><img src="http://www.x2od.com/wp/uploads/EmailInbox-screenshot-300x50.jpg" alt="EmailInbox screenshot" title="EmailInbox screenshot" width="300" height="50" class="aligncenter size-medium wp-image-672" /></a></center>
<p>Here's the updated Visualforce code:</p>
<pre class="brush: xml;">
&lt;apex:page controller=&quot;EmailMessageController&quot; action=&quot;{!ViewData}&quot;&gt;
    &lt;apex:sectionHeader title=&quot;Email Messages&quot; subtitle=&quot;&quot;&gt;&lt;/apex:sectionHeader&gt;
    &lt;apex:pageblock id=&quot;emailblock&quot;&gt;
        &lt;apex:facet name=&quot;header&quot;&gt;
            &lt;apex:form &gt;
                &lt;apex:panelGrid styleClass=&quot;list&quot;
                    columnClasses=&quot;pbTitle,pbButton,pbHelp&quot; columns=&quot;3&quot; border=&quot;0&quot;
                    cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;
                    &lt;apex:outputLabel &gt;&lt;h3&gt;Messages&lt;/h3&gt;&lt;/apex:outputLabel&gt;
                    &lt;apex:commandButton value=&quot; Refresh &quot; styleClass=&quot;btn&quot;
                        action=&quot;{!ViewData}&quot; rerender=&quot;emailblock&quot;&gt;&lt;/apex:commandButton&gt;
                    &lt;apex:SelectList value=&quot;{!wheretext}&quot; size=&quot;1&quot;  id=&quot;controllerselectlist&quot;&gt;
                        &lt;apex:actionSupport event=&quot;onchange&quot; action=&quot;{!ViewData}&quot;
                            reRender=&quot;emailblock&quot;&gt;&lt;/apex:actionSupport&gt;
                        &lt;apex:selectOptions value=&quot;{!views}&quot; /&gt;
                    &lt;/apex:SelectList&gt;
                &lt;/apex:panelGrid&gt;
            &lt;/apex:form&gt;
        &lt;/apex:facet&gt;
        &lt;apex:form &gt;
            &lt;apex:pageblocktable value=&quot;{!Messages}&quot; var=&quot;e&quot; id=&quot;emailtable&quot;
                bgcolor=&quot;#F3F3EC&quot; styleClass=&quot;list&quot; rowClasses=&quot;dataRow&quot;
                onRowMouseOver=&quot;hiOn(this);&quot; onRowMouseOut=&quot;hiOff(this);&quot;&gt;
                &lt;apex:column &gt;
                    &lt;apex:facet name=&quot;header&quot;&gt;
                        &lt;apex:commandLink action=&quot;{!ViewData}&quot;
                            value=&quot;{!$ObjectType.EmailMessage.fields.Subject.label}{!IF(sortExpression=='Subject', 
                            IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
                            &lt;apex:param value=&quot;Subject&quot; name=&quot;column&quot;
                                assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
                        &lt;/apex:commandLink&gt;
                    &lt;/apex:facet&gt;
                    &lt;apex:outputLink value=&quot;/{!e.Id}&quot; target=&quot;_blank&quot;&gt;{!e.Subject}&lt;/apex:outputLink&gt;
                &lt;/apex:column&gt;
                &lt;apex:column &gt;
                    &lt;apex:facet name=&quot;header&quot;&gt;
                    {!$ObjectType.Contact.fields.Name.label}
                    &lt;/apex:facet&gt;
                    &lt;apex:outputLink value=&quot;/{!e.Parent.ContactId}&quot; target=&quot;_blank&quot;
                        rendered=&quot;{!IF(e.Parent.ContactId != '',true,false)}&quot;&gt;{!e.FromName}&lt;/apex:outputLink&gt;
                    &lt;apex:outputtext value=&quot;{!e.FromName}&quot;
                        rendered=&quot;{!IF(e.Parent.ContactId != '',false,true)}&quot; /&gt;
                &lt;/apex:column&gt;
                &lt;apex:column &gt;
                    &lt;apex:facet name=&quot;header&quot;&gt;
                    {!$ObjectType.Account.fields.Name.label}
                    &lt;/apex:facet&gt;
                    &lt;apex:outputLink value=&quot;/{!e.Parent.AccountId}&quot; target=&quot;_blank&quot;&gt;{!e.Parent.Account.Name}&lt;/apex:outputLink&gt;
                &lt;/apex:column&gt;
                &lt;apex:column value=&quot;{!e.FromAddress}&quot;&gt;
                    &lt;apex:facet name=&quot;header&quot;&gt;
                        &lt;apex:commandLink action=&quot;{!ViewData}&quot;
                            value=&quot;{!$ObjectType.EmailMessage.fields.FromAddress.label}{!IF(sortExpression=='FromAddress', 
                            IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
                            &lt;apex:param value=&quot;FromAddress&quot; name=&quot;column&quot;
                                assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
                        &lt;/apex:commandLink&gt;
                    &lt;/apex:facet&gt;
                &lt;/apex:column&gt;
                &lt;apex:column value=&quot;{!e.Status}&quot;&gt;
                    &lt;apex:facet name=&quot;header&quot;&gt;
                        &lt;apex:commandLink action=&quot;{!ViewData}&quot;
                            value=&quot;{!$ObjectType.EmailMessage.fields.Status.label}{!IF(sortExpression=='Status', 
                            IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
                            &lt;apex:param value=&quot;Status&quot; name=&quot;column&quot;
                                assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
                        &lt;/apex:commandLink&gt;
                    &lt;/apex:facet&gt;
                &lt;/apex:column&gt;
                &lt;apex:column value=&quot;{!e.MessageDate}&quot;&gt;
                    &lt;apex:facet name=&quot;header&quot;&gt;
                        &lt;apex:commandLink action=&quot;{!ViewData}&quot;
                            value=&quot;{!$ObjectType.EmailMessage.fields.MessageDate.label}{!IF(sortExpression=='MessageDate', 
                            IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
                            &lt;apex:param value=&quot;MessageDate&quot; name=&quot;column&quot;
                                assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
                        &lt;/apex:commandLink&gt;
                    &lt;/apex:facet&gt;
                &lt;/apex:column&gt;
                &lt;apex:column &gt;
                    &lt;apex:facet name=&quot;header&quot;&gt;
                        &lt;apex:commandLink action=&quot;{!ViewData}&quot;
                            value=&quot;Inbound/Outbound{!IF(sortExpression=='Incoming', 
                            IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
                            &lt;apex:param value=&quot;Incoming&quot; name=&quot;column&quot;
                                assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
                        &lt;/apex:commandLink&gt;
                    &lt;/apex:facet&gt;
                    &lt;apex:image url=&quot;/img/emailInbound.gif&quot; rendered=&quot;{!e.Incoming}&quot; /&gt;
                    &lt;apex:image url=&quot;/img/emailOutbound.gif&quot; rendered=&quot;{!NOT(e.Incoming)}&quot; /&gt;
                    &lt;!--&lt;apex:outputfield value=&quot;{!e.Incoming}&quot; rendered=&quot;{!NOT(e.Incoming)}&quot; /&gt;--&gt;
                &lt;/apex:column&gt;
                &lt;apex:column &gt;
                    &lt;apex:facet name=&quot;header&quot;&gt;
                        &lt;apex:commandLink action=&quot;{!ViewData}&quot;
                            value=&quot;Attachment{!IF(sortExpression=='HasAttachment', 
                            IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
                            &lt;apex:param value=&quot;HasAttachment&quot; name=&quot;column&quot;
                                assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
                        &lt;/apex:commandLink&gt;
                    &lt;/apex:facet&gt;
                    &lt;apex:image url=&quot;/img/emailHasAttach.gif&quot; rendered=&quot;{!e.HasAttachment}&quot;/&gt;
                    &lt;apex:outputfield value=&quot;{!e.HasAttachment}&quot; rendered=&quot;{!NOT(e.HasAttachment)}&quot; /&gt;
                &lt;/apex:column&gt;
                &lt;apex:column &gt;
                    &lt;apex:facet name=&quot;header&quot;&gt;
                        &lt;apex:commandLink action=&quot;{!ViewData}&quot;
                            value=&quot;{!$ObjectType.Case.fields.CaseNumber.label}{!IF(sortExpression=='ParentId', 
                            IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
                            &lt;apex:param value=&quot;ParentId&quot; name=&quot;column&quot;
                                assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
                        &lt;/apex:commandLink&gt;
                    &lt;/apex:facet&gt;
                    &lt;apex:outputLink value=&quot;/{!e.ParentId}&quot;&gt;{!e.Parent.CaseNumber}&lt;/apex:outputLink&gt;

                &lt;/apex:column&gt;
                &lt;apex:column value=&quot;{!e.ToAddress}&quot;&gt;
                    &lt;apex:facet name=&quot;header&quot;&gt;
                        &lt;apex:commandLink action=&quot;{!ViewData}&quot;
                            value=&quot;{!$ObjectType.EmailMessage.fields.ToAddress.label}{!IF(sortExpression=='ToAddress', 
                            IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
                            &lt;apex:param value=&quot;ToAddress&quot; name=&quot;column&quot;
                                assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
                        &lt;/apex:commandLink&gt;
                    &lt;/apex:facet&gt;
                &lt;/apex:column&gt;
            &lt;/apex:pageblocktable&gt;
        &lt;/apex:form&gt;
    &lt;/apex:pageblock&gt;
&lt;/apex:page&gt;
</pre>
<p>The Apex controller code has not changed from <a href="http://www.x2od.com/2009/07/14/visualforce-email-inbox.html">Version 1</a>.  </p>
<p>Here's the screenshot, which includes some emails from around the Salesforce ecosystem:</p>
<center>
<div id="attachment_666" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.x2od.com/wp/uploads/EmailInbox-screenshot-2.JPG"><img src="http://www.x2od.com/wp/uploads/EmailInbox-screenshot-2-300x110.jpg" alt="Incoming (and auto-response) Emails" title="EmailInbox screenshot" width="300" height="110" class="size-medium wp-image-666" /></a><p class="wp-caption-text">Incoming (and auto-response) Emails</p></div></center>

Things to notice and things we've learned:
<ol>
	<li>Salesforce will search ANY Email field to match an incoming email to a Contact. (nice job, Salesforce!) - We know because <a href="http://www.pocketsoap.com">Simon Fell</a>'s Contact.Email is sfell at salesforce.com, and his Contact.Secondary_Email__c is simon at fell.com in the sandbox.  Ditto (with her own email addresses) for <a href="http://www.xlerate.ca/">Irene Brodt</a>.</li>
	<li>Auto-response emails will be included.  We turned off auto-response after a few emails came in.</li>
	<li>Though the Email Address field is coded just to show the field value, Salesforce includes the Gmail link. (We assume that's because we activated the integration, but we may be wrong. Has anyone not activated that?)</li>
	<li>We did not (yet) implement the <a href="http://blogs.salesforce.com/support/2009/03/autocreating-a.html">super Email/Web2Case trigger code</a> that Marco Casalaina posted in the Salesforce Support Blog, but if we had, then every email in the list would be associated with a Contact. (Example: Michael Smith of Force2b.net, who will be a Contact from now on!)</li>
</ol>
Enjoy!  ]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2009/07/15/email-inbox-version-2.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Visualforce Email Inbox</title>
		<link>http://www.x2od.com/2009/07/14/visualforce-email-inbox.html</link>
		<comments>http://www.x2od.com/2009/07/14/visualforce-email-inbox.html#comments</comments>
		<pubDate>Tue, 14 Jul 2009 18:00:26 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Visualforce]]></category>
		<category><![CDATA[X-Squared On Demand]]></category>
		<category><![CDATA[salesforce.com]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=642</guid>
		<description><![CDATA[Sonny Cloward, SysAd at Rainforest Alliance, approached us about writing a Visualforce page to display all incoming emails for a given Case Queue. This led to quite a few interesting discoveries. Here's how we handled the project:]]></description>
			<content:encoded><![CDATA[<p>Sonny Cloward, SysAd at <a href="http://rainforestalliance.org/">Rainforest Alliance</a>, approached us about writing a Visualforce page to display all incoming emails for a given Case Queue.  This led a few interesting discoveries.  Here's how we handled the (donated time) project:</p>
<p>First, the page was built upon the <a href="http://salesforcesource.blogspot.com/2008/11/adding-sorting-capability-to.html">template Sam Arjimandi built</a> at <a href="http://salesforcesource.blogspot.com">Salesforce<Source></a>.  Instead of the Account object, we substituted the <a href="http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_emailmessage.htm">EmailMessage object</a>.  But something didn't work.  </p>
Fields have certain <a href="http://www.salesforce.com/us/developer/docs/api/Content/access_for_fields.htm">attributes</a>:<br />
            <table cellpadding="4" cellspacing="0" summary="" class="featureTable">
                <thead align="left">
                    <tr>
                        <th class="featureTableHeader" width="25%" id="d9607e40" colspan="1" rowspan="1">Property</th>
                        <th class="featureTableHeader" width="75%" id="d9607e43" colspan="1" rowspan="1">Description</th>
                    </tr>
                </thead>
                <tbody>

                    <tr>
                        <td width="25%" headers="d9607e40" colspan="1" rowspan="1"><span id="i1435186"><a name="i1435186" shape="rect"><!-- --></a>Autonumber</span>
                        </td>
                        <td width="75%" headers="d9607e43" colspan="1" rowspan="1">The <span>API</span> creates an autonumber.</td>
                    </tr>
                    <tr>

                        <td width="25%" headers="d9607e40" colspan="1" rowspan="1"><span id="i1435191"><a name="i1435191" shape="rect"><!-- --></a>Create</span>
                        </td>
                        <td width="75%" headers="d9607e43" colspan="1" rowspan="1">Value for the field can be specified during create using the <span>API</span>.</td>
                    </tr>
                    <tr>
                        <td width="25%" headers="d9607e40" colspan="1" rowspan="1"><span id="i1435199"><a name="i1435199" shape="rect"><!-- --></a>Defaulted on create</span>

                        </td>
                        <td width="75%" headers="d9607e43" colspan="1" rowspan="1">When created, a default value is supplied if no other value
is specified.</td>
                    </tr>
                    <tr>
                        <td width="25%" headers="d9607e40" colspan="1" rowspan="1"><span id="i1435204"><a name="i1435204" shape="rect"><!-- --></a>Delete</span>
                        </td>
                        <td width="75%" headers="d9607e43" colspan="1" rowspan="1">Value for the field can be deleted using the <span>API</span>.</td>

                    </tr>
                    <tr>
                        <td width="25%" headers="d9607e40" colspan="1" rowspan="1"><span id="i1435212"><a name="i1435212" shape="rect"><!-- --></a>Filter</span>
                        </td>
                        <td width="75%" headers="d9607e43" colspan="1" rowspan="1">Can be used as filter criteria in a SOQL query FROM or WHERE
clause.</td>
                    </tr>
                    <tr>
                        <td width="25%" headers="d9607e40" colspan="1" rowspan="1"><span id="access_lookup"><a name="access_lookup" shape="rect"><!-- --></a>idLookup</span>

                        </td>
                        <td width="75%" headers="d9607e43" colspan="1" rowspan="1">Can be used to specify a record in an <span><a href="sforce_api_calls_upsert.htm" shape="rect"><span><samp class="codeph">upsert()</samp></span></a></span> call. The <span class="fieldName">Id</span> field of each
object has this property and some <span class="fieldName">Name</span> fields. <span>There are exceptions, so check for the property in
any object you wish to <a href="sforce_api_calls_upsert.htm" shape="rect"><span><samp class="codeph">upsert()</samp></span>.</a></span></td>

                    </tr>
                    <tr>
                        <td width="25%" headers="d9607e40" colspan="1" rowspan="1"><span id="i1435217"><a name="i1435217" shape="rect"><!-- --></a>Nillable</span>
                        </td>
                        <td width="75%" headers="d9607e43" colspan="1" rowspan="1">The field can contain a null value.</td>
                    </tr>
                    <tr>
                        <td width="25%" headers="d9607e40" colspan="1" rowspan="1"><span id="i1435222"><a name="i1435222" shape="rect"><!-- --></a>Query</span>

                        </td>
                        <td width="75%" headers="d9607e43" colspan="1" rowspan="1">The field can be queried with SOQL using the <span>API</span>.</td>
                    </tr>
                    <tr>
                        <td width="25%" headers="d9607e40" colspan="1" rowspan="1"><span id="i1435230"><a name="i1435230" shape="rect"><!-- --></a>Replicate</span>
                        </td>
                        <td width="75%" headers="d9607e43" colspan="1" rowspan="1">The value of the field can be replicated using the <span>API</span>.</td>

                    </tr>
                    <tr>
                        <td width="25%" headers="d9607e40" colspan="1" rowspan="1"><span id="i1435238"><a name="i1435238" shape="rect"><!-- --></a>Restricted picklist</span>
                        </td>
                        <td width="75%" headers="d9607e43" colspan="1" rowspan="1">  A picklist that depends on the value of another picklist
for the values it displays.</td>
                    </tr>
                    <tr>

                        <td width="25%" headers="d9607e40" colspan="1" rowspan="1"><span id="i1435244"><a name="i1435244" shape="rect"><!-- --></a>Retrieve</span>
                        </td>
                        <td width="75%" headers="d9607e43" colspan="1" rowspan="1">Value of the field can be retrieved using the <span>API</span>.</td>
                    </tr>
                    <tr>
                        <td width="25%" headers="d9607e40" colspan="1" rowspan="1"><span id="field_access_search"><a name="field_access_search" shape="rect"><!-- --></a>Search</span>

                        </td>
                        <td width="75%" headers="d9607e43" colspan="1" rowspan="1">Can be searched with SOSL using the <span>API</span>.</td>
                    </tr>
                    <tr>
                        <td width="25%" headers="d9607e40" colspan="1" rowspan="1"><span id="i1435259"><a name="i1435259" shape="rect"><!-- --></a>Update</span>
                        </td>
                        <td width="75%" headers="d9607e43" colspan="1" rowspan="1">Can be updated using the <span>API</span>.</td>

                    </tr>
                </tbody>
            </table>
<p>The important one here is "Filter" because (as the documentation states) this allows the field to be used in a WHERE clause.  Also, however, (as the documentation does not state) it allows the field to be used in an ORDER BY clause.  So all fields on the EmailMessage object that do not allow filtering/ordering had to be presented plainly, without Sam's cool PageBlockTable sorting features.
Once this was done, Sonny had some great ideas:</p>
<ol>
	<li>Show the email subject, but make that a hyperlink to the email message itself</li>
	<li>Link the Case Number (EmailMessage.ParentId) to the Case (EmailMessage.Parent)</li>
	<li>Show the Case Contact (EmailMessage.Parent.Contact.Name), linking to the Contact (EmailMessage.Parent.ContactId)</li>
	<li>Show the Case Account (EmailMessage.Parent.Account.Name), linking to the Account (EmailMessage.Parent.AccountId)</li>
	<li>Provide filters - Incoming only, Unread only, etc.</li>
</ol>
You'll see in the Apex Code where we added parent object fields to the SOQL query, and where we used a List<SelectOption> to populate the query's filter.  
<pre class="brush: java;">
public with sharing class EmailMessageController {
   public String EmailMessage { get; set; }
   private List&lt;EmailMessage&gt; messages;
   private String sortDirection = 'ASC';
   private String sortExp = 'MessageDate';
   public String wheretext;

   public EmailMessageController(){
   	wheretext = '';
   }

   public String sortExpression { get {
        return sortExp;
     }
     set {
       //if the column is clicked on then switch between Ascending and Descending modes
       if (value == sortExp)
         sortDirection = (sortDirection == 'ASC')? 'DESC' : 'ASC';
       else
         sortDirection = 'ASC';
       sortExp = value;
     }
   }
   
public void setWhereText(String value) {  
   whereText = value;
 }
public string getWhereText(){
	return wheretext;
}
   
public List&lt;SelectOption&gt; getViews(){
	List&lt;SelectOption&gt; options = new List&lt;SelectOption&gt;();
	options.add(new SelectOption('WHERE e.id != null','All'));
	options.add(new SelectOption('WHERE e.Incoming = true AND e.Status = \'0\' ','Incoming Unread'));
	options.add(new SelectOption('WHERE e.Incoming = true AND e.Status = \'1\' ','Incoming Read'));
        options.add(new SelectOption('WHERE e.Incoming = true','All Incoming'));
        options.add(new SelectOption('WHERE e.Incoming = false','All Outgoing'));
        options.add(new SelectOption('WHERE e.ToAddress = \'support@x2od.com\'','Support Queue'));
        options.add(new SelectOption('WHERE e.ToAddress = \'support2@x2od.com\'','Support Queue2')); //etc.
        return options;
}

 public String getSortDirection() {
    //if not column is selected 
    if (sortExpression == null || sortExpression == '')
      return 'ASC';
    else
     return sortDirection;
 }

 public void setSortDirection(String value) {  
   sortDirection = value;
 }
  
   public List&lt;EmailMessage&gt; getMessages() {
       return messages;
   }
   
   public PageReference ViewData() {
       //build the full sort expression
       string sortFullExp = sortExpression  + ' ' + sortDirection;
      
       //query the database based on the sort expression
       messages = Database.query('Select e.FromAddress, e.Parent.ContactId, e.Parent.Contact.Name, e.Parent.Account.Name, e.ToAddress, e.Parent.CaseNumber, e.Parent.AccountId, e.TextBody, e.SystemModstamp, e.Subject, e.Status, e.ParentId, e.MessageDate, e.LastModifiedDate, e.LastModifiedById, e.IsDeleted, e.Incoming, e.Id, e.HtmlBody, e.Headers, e.HasAttachment, e.FromName, e.CreatedDate, e.CreatedById, e.CcAddress, e.BccAddress, e.ActivityId From EmailMessage e ' + wheretext + ' order by ' + sortFullExp + ' limit 1000');
       return null;
   }
}
</pre>
<p>And here's the Visualforce Page:</p>
<pre class="brush: xml;">
&lt;apex:page controller=&quot;EmailMessageController&quot; action=&quot;{!ViewData}&quot;&gt;
	&lt;apex:sectionHeader title=&quot;Email Messages&quot; subtitle=&quot;&quot;&gt;&lt;/apex:sectionHeader&gt;
	&lt;apex:pageblock id=&quot;emailblock&quot;&gt;
		&lt;apex:facet name=&quot;header&quot;&gt;
			&lt;apex:form&gt;
				&lt;apex:panelGrid styleClass=&quot;list&quot;
					columnClasses=&quot;pbTitle,pbButton,pbHelp&quot; columns=&quot;3&quot; border=&quot;0&quot;
					cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;
					&lt;apex:outputLabel&gt;&lt;h3&gt;Messages&lt;/h3&gt;&lt;/apex:outputLabel&gt;
					&lt;apex:commandButton value=&quot; Refresh &quot; styleClass=&quot;btn&quot;
						action=&quot;{!ViewData}&quot; rerender=&quot;emailblock&quot;&gt;&lt;/apex:commandButton&gt;
					&lt;apex:SelectList value=&quot;{!wheretext}&quot; size=&quot;1&quot;	id=&quot;controllerselectlist&quot;&gt;
						&lt;apex:actionSupport event=&quot;onchange&quot; action=&quot;{!ViewData}&quot;
							reRender=&quot;emailblock&quot;&gt;&lt;/apex:actionSupport&gt;
						&lt;apex:selectOptions value=&quot;{!views}&quot; /&gt;
					&lt;/apex:SelectList&gt;
				&lt;/apex:panelGrid&gt;
			&lt;/apex:form&gt;
		&lt;/apex:facet&gt;
		&lt;apex:form&gt;
			&lt;apex:pageblocktable value=&quot;{!Messages}&quot; var=&quot;e&quot; id=&quot;emailtable&quot;
				bgcolor=&quot;#F3F3EC&quot; styleClass=&quot;list&quot; rowClasses=&quot;dataRow&quot;
				onRowMouseOver=&quot;hiOn(this);&quot; onRowMouseOut=&quot;hiOff(this);&quot;&gt;
				&lt;apex:column&gt;
					&lt;apex:facet name=&quot;header&quot;&gt;
						&lt;apex:commandLink action=&quot;{!ViewData}&quot;
							value=&quot;{!$ObjectType.EmailMessage.fields.Subject.label}{!IF(sortExpression=='Subject', 
							IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
							&lt;apex:param value=&quot;Subject&quot; name=&quot;column&quot;
								assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
						&lt;/apex:commandLink&gt;
					&lt;/apex:facet&gt;
					&lt;apex:outputLink value=&quot;/{!e.Id}&quot; target=&quot;_blank&quot;&gt;{!e.Subject}&lt;/apex:outputLink&gt;
				&lt;/apex:column&gt;
				&lt;apex:column&gt;
					&lt;apex:facet name=&quot;header&quot;&gt;
					{!$ObjectType.Contact.fields.Name.label}
					&lt;/apex:facet&gt;
					&lt;apex:outputLink value=&quot;/{!e.Parent.ContactId}&quot; target=&quot;_blank&quot;
						rendered=&quot;{!IF(e.Parent.ContactId != '',true,false)}&quot;&gt;{!e.FromName}&lt;/apex:outputLink&gt;
					&lt;apex:outputtext value=&quot;{!e.FromName}&quot;
						rendered=&quot;{!IF(e.Parent.ContactId != '',false,true)}&quot; /&gt;
				&lt;/apex:column&gt;
				&lt;apex:column&gt;
					&lt;apex:facet name=&quot;header&quot;&gt;
					{!$ObjectType.Account.fields.Name.label}
					&lt;/apex:facet&gt;
					&lt;apex:outputLink value=&quot;/{!e.Parent.AccountId}&quot; target=&quot;_blank&quot;&gt;{!e.Parent.Account.Name}&lt;/apex:outputLink&gt;
				&lt;/apex:column&gt;
				&lt;apex:column value=&quot;{!e.FromAddress}&quot;&gt;
					&lt;apex:facet name=&quot;header&quot;&gt;
						&lt;apex:commandLink action=&quot;{!ViewData}&quot;
							value=&quot;{!$ObjectType.EmailMessage.fields.FromAddress.label}{!IF(sortExpression=='FromAddress', 
							IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
							&lt;apex:param value=&quot;FromAddress&quot; name=&quot;column&quot;
								assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
						&lt;/apex:commandLink&gt;
					&lt;/apex:facet&gt;
				&lt;/apex:column&gt;
				&lt;apex:column value=&quot;{!e.Status}&quot;&gt;
					&lt;apex:facet name=&quot;header&quot;&gt;
						&lt;apex:commandLink action=&quot;{!ViewData}&quot;
							value=&quot;{!$ObjectType.EmailMessage.fields.Status.label}{!IF(sortExpression=='Status', 
							IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
							&lt;apex:param value=&quot;Status&quot; name=&quot;column&quot;
								assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
						&lt;/apex:commandLink&gt;
					&lt;/apex:facet&gt;
				&lt;/apex:column&gt;
				&lt;apex:column value=&quot;{!e.MessageDate}&quot;&gt;
					&lt;apex:facet name=&quot;header&quot;&gt;
						&lt;apex:commandLink action=&quot;{!ViewData}&quot;
							value=&quot;{!$ObjectType.EmailMessage.fields.MessageDate.label}{!IF(sortExpression=='MessageDate', 
							IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
							&lt;apex:param value=&quot;MessageDate&quot; name=&quot;column&quot;
								assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
						&lt;/apex:commandLink&gt;
					&lt;/apex:facet&gt;
				&lt;/apex:column&gt;
				&lt;apex:column value=&quot;{!e.Incoming}&quot;&gt;
					&lt;apex:facet name=&quot;header&quot;&gt;
						&lt;apex:commandLink action=&quot;{!ViewData}&quot;
							value=&quot;{!$ObjectType.EmailMessage.fields.Incoming.label}{!IF(sortExpression=='Incoming', 
							IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
							&lt;apex:param value=&quot;Incoming&quot; name=&quot;column&quot;
								assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
						&lt;/apex:commandLink&gt;
					&lt;/apex:facet&gt;
				&lt;/apex:column&gt;
				&lt;apex:column value=&quot;{!e.HasAttachment}&quot;&gt;
					&lt;apex:facet name=&quot;header&quot;&gt;
						&lt;apex:commandLink action=&quot;{!ViewData}&quot;
							value=&quot;{!$ObjectType.EmailMessage.fields.HasAttachment.label}{!IF(sortExpression=='HasAttachment', 
							IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
							&lt;apex:param value=&quot;HasAttachment&quot; name=&quot;column&quot;
								assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
						&lt;/apex:commandLink&gt;
					&lt;/apex:facet&gt;
				&lt;/apex:column&gt;
				&lt;apex:column&gt;
					&lt;apex:facet name=&quot;header&quot;&gt;
						&lt;apex:commandLink action=&quot;{!ViewData}&quot;
							value=&quot;{!$ObjectType.Case.fields.CaseNumber.label}{!IF(sortExpression=='ParentId', 
							IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
							&lt;apex:param value=&quot;ParentId&quot; name=&quot;column&quot;
								assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
						&lt;/apex:commandLink&gt;
					&lt;/apex:facet&gt;
					&lt;apex:outputLink value=&quot;/{!e.ParentId}&quot;&gt;{!e.Parent.CaseNumber}&lt;/apex:outputLink&gt;

				&lt;/apex:column&gt;
				&lt;apex:column value=&quot;{!e.ToAddress}&quot;&gt;
					&lt;apex:facet name=&quot;header&quot;&gt;
						&lt;apex:commandLink action=&quot;{!ViewData}&quot;
							value=&quot;{!$ObjectType.EmailMessage.fields.ToAddress.label}{!IF(sortExpression=='ToAddress', 
							IF(sortDirection='ASC','▼','▲'),'')}&quot;&gt;
							&lt;apex:param value=&quot;ToAddress&quot; name=&quot;column&quot;
								assignTo=&quot;{!sortExpression}&quot;&gt;&lt;/apex:param&gt;
						&lt;/apex:commandLink&gt;
					&lt;/apex:facet&gt;
				&lt;/apex:column&gt;
			&lt;/apex:pageblocktable&gt;
		&lt;/apex:form&gt;
	&lt;/apex:pageblock&gt;
&lt;/apex:page&gt;
</pre>
<p>There are some other cool bits: </p>
<p>If there is no Case.Contact, the table will display the FromName, pulled from the email message.</p>
<p>An interesting point: You may notice that EmailStatus is presented in numerical form.  For instance, Incoming Unread is 0, Incoming Read is 1, etc.  The documentation, however, says, "Read only. The status of the email. For example, “New,” “Unread,” “Replied,” “Sent.”"  So we're not sure of the exact mapping.  3 seems to be Sent, so 2 is probably Replied... but we're not sure.</p>
<p>Don't forget: EmailMessage has two lookups (foreign key): Case, and Activity.  This Activity is the task created when Salesforce receives the email, and is - according to the documentation - assigned to the Case Owner.  We're not sure what happens when the Case is owned by a Queue.  Feel free to comment and share your experiences.</p>
<p>
That's it!  Enjoy.</p>]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2009/07/14/visualforce-email-inbox.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Eclipse as a Password Manager</title>
		<link>http://www.x2od.com/2009/07/10/eclipse-as-a-password-manager.html</link>
		<comments>http://www.x2od.com/2009/07/10/eclipse-as-a-password-manager.html#comments</comments>
		<pubDate>Fri, 10 Jul 2009 19:33:11 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[salesforce.com]]></category>
		<category><![CDATA[Eclipse IDE]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=625</guid>
		<description><![CDATA[Recently, Judi Sohn wrote about a URL hack to save your Salesforce username and password (in an exposed, plaintext manner). This is a great way to save a lot of time logging into Salesforce.

There is another way to save un/pw combinations: Use Eclipse to store the un/pw/securitytoken.

Read more: http://www.x2od.com/?p=625&#038;preview=true#ixzz0Kt2X1lQD&#038;C]]></description>
			<content:encoded><![CDATA[<p>Caution: Only use this tip if your computer is SECURE.  </p>

<p>Recently, Judi Sohn <a href="http://www.judisohn.com/2009/06/tip_easy_salesforce_logins/">wrote about a URL hack</a> to save your Salesforce username and password (in an exposed, plaintext manner).  This is a great way to save a lot of time logging into Salesforce. </p>

<p>There is another way to save un/pw combinations: Use Eclipse to store the un/pw/securitytoken.  There's a catch (there always is): Once they're entered, you can't see them in plaintext for, say, doing a copy/paste of your token into <a href="https://na1.salesforce.com/setup/outlook/outlooksetup2.jsp?retURL=%2Fui%2Fsetup%2FSetup%3Fsetupid%3DDesktopIntegration&setupid=OutlookEdition">Connect for Outlook</a>, <a href="http://wiki.developerforce.com/index.php/Force.com_Excel_Connector">Excel Connector</a>, etc.</p>

<p>For each client, I create a project in the <a href="http://wiki.developerforce.com/index.php/Force.com_IDE">Eclipse Force.com IDE</a>, entering the username, password, and security token into the appropriate form.  (This does require me to have a System Administrator, or at least "View All Data" and possibly "Edit All Data" profile permissions.)  Then, instead of getting into Salesforce through the browser, I open a file in the project, such as an Apex Class, right-click, and select "Show in Salesforce Web."  The browser does the rest, opening the org, and taking me to that Apex Class.  It does not take me to the Home screen, but I'm willing to use that one extra click.  Plus, it's nice to get directly into the Setup area sometimes.</p>

<p><a href="http://www.x2od.com/wp/uploads/ShowInSalesforceWeb.jpg"><img src="http://www.x2od.com/wp/uploads/ShowInSalesforceWeb.jpg" alt="ShowInSalesforceWeb" title="ShowInSalesforceWeb" width="224" height="238" class="aligncenter size-full wp-image-630" /></a></p>

<p>That's it!  Keep all your projects in Eclipse, and (as long as you're a developer and work in Eclipse a lot) it will save time.</p>

<p>To reiterate the above caution: Anyone who can open Eclipse can get into any of those orgs, so be careful with this!  Always secure your computer.  On Vista, require a password when waking from the screen saver, and use other security features whenever possible.  <br clear="both" />]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2009/07/10/eclipse-as-a-password-manager.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Checkbox Formula Field in Visualforce</title>
		<link>http://www.x2od.com/2009/05/21/checkbox-formula-field-in-visualforce.html</link>
		<comments>http://www.x2od.com/2009/05/21/checkbox-formula-field-in-visualforce.html#comments</comments>
		<pubDate>Thu, 21 May 2009 17:00:52 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Visualforce]]></category>
		<category><![CDATA[salesforce.com]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=609</guid>
		<description><![CDATA[In keeping with the theme of checkboxes and formulas, we provide an easy way to create a checkbox formula field using Visualforce: the checkbox tag with the disabled attribute:]]></description>
			<content:encoded><![CDATA[<p>In keeping with the theme of <a href="http://www.x2od.com/2009/05/11/standard-checkbox-images.html">checkboxes</a> and formulas, we provide an easy way to create a checkbox formula field using Visualforce: the checkbox tag with the disabled attribute:</p>
<p>First, the Apex controller method:</p>
<pre class="brush: java;">
public boolean checkformula(){
boolean b = [insert formula here];
return b;
}
</pre>
<p>And the visualforce code:</p>
<pre class="brush: xml;">
&lt;apex:inputCheckbox disabled=&quot;true&quot; value=&quot;{!checkformula}&quot;/&gt;
</pre>
<p>That's it!  Of course, there are many ways to set up the Apex method, but the important piece is the Visualforce markup.  By using a tag usually associated with an edit page but making it disabled, the checkbox becomes an output field.</p>]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2009/05/21/checkbox-formula-field-in-visualforce.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pulling Code Out of Triggers</title>
		<link>http://www.x2od.com/2009/05/18/pulling-code-out-of-triggers.html</link>
		<comments>http://www.x2od.com/2009/05/18/pulling-code-out-of-triggers.html#comments</comments>
		<pubDate>Mon, 18 May 2009 17:00:41 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Summer 09]]></category>
		<category><![CDATA[salesforce.com]]></category>
		<category><![CDATA[Eclipse IDE]]></category>
		<category><![CDATA[Force.com Platform]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=583</guid>
		<description><![CDATA[To date, triggers have only been accessible on each object's setup page, leading to a lot of hunting for code within the Salesforce CRM application. Even in Eclipse, switching between the Class and Trigger folders for a given project can be a pain.

These pains can partially be alleviated by keeping all Apex code in one place--as Apex Classes.

Read more: http://www.x2od.com/?p=583&#038;preview=true#ixzz0FncHsqPw&#038;B]]></description>
			<content:encoded><![CDATA[<p>To date, triggers have only been accessible on each object's setup page, leading to a lot of hunting for code within the Salesforce CRM application.  Even in Eclipse, switching between the Class and Trigger folders for a given project can be a pain.</p>
<p>These pains can partially be alleviated by keeping all Apex code in one place--as Apex Classes.  With the addition of a consolidated trigger list in <a href="http://wiki.developerforce.com/index.php/Summer_09">Summer09</a>, some may feel that this post is superfluous, but consolidating code in one place, combined with the trigger list, will lead to a better development, debugging, and org administration experience.</p>

<p>First, here's a sample trigger (written by <a href="http://blog.jeffdouglas.com/2009/04/20/writing-bulk-triggers-for-salesforce">Jeff Douglas</a>):</p>
<pre class="brush: java;">
trigger AddOwnerColor on Account (before insert, before update) {

    // create a set of all the unique ownerIds
    Set&amp;lt;Id&amp;gt; ownerIds = new Set&amp;lt;Id&amp;gt;();
    for (Account a : Trigger.new)
        ownerIds.add(a.OwnerId);    

    // query for all the User records for the unique userIds in the records
    // create a map for a lookup / hash table for the user info
    Map&amp;lt;Id, User&amp;gt; owners = new Map&amp;lt;Id, User&amp;gt;([Select Favorite_Color__c from User Where Id in: ownerIds]);   

    // iterate over the list of records being processed in the trigger and
    // set the color before being inserted or updated
    for (Account a : Trigger.new)
        a.Owner_Favorite_Color__c = owners.get(a.OwnerId).Favorite_Color__c; 
}
</pre>
<p>Let's pull the code from the trigger into an Apex Class and leave a reference to that class & method in the trigger.  We need to pass the list Trigger.new as a parameter to the new class's method:<p>
The trigger:
<pre class="brush: java;">
trigger AddOwnerColor on Account (before insert, before update) {
AccountTriggers.AddOwnerColor(Trigger.new);
}
</pre>
And the class:
<pre class="brush: java;">
public class AccountTriggers {
    public static void AddOwnerColor(Account[] accts) {

    // create a set of all the unique ownerIds
    Set&amp;lt;Id&amp;gt; ownerIds = new Set&amp;lt;Id&amp;gt;();
    for (Account a : accts)
        ownerIds.add(a.OwnerId);    

    // query for all the User records for the unique userIds in the records
    // create a map for a lookup / hash table for the user info
    Map&amp;lt;Id, User&amp;gt; owners = new Map&amp;lt;Id, User&amp;gt;([Select Favorite_Color__c from User Where Id in: ownerIds]);   

    // iterate over the list of records being processed in the trigger and
    // set the color before being inserted or updated
    for (Account a : accts)
        a.Owner_Favorite_Color__c = owners.get(a.OwnerId).Favorite_Color__c; 
    } // close AddOwnerColor
}
</pre>
While this may seem trivial, it has a few advantages:<p>
<ul>
	<li>Easier to work in Eclipse (all code in the Classes section)</li>
	<li>Easier to write test code (can see tests and their associated methods in one place)</li>
	<li>Can promote code reuse by allowing other classes and triggers to call the same method.</li>
	<li>For those who like to include test code in the same class as the regular Class, this allows them to do so.</li>
</ul>
<p>There's a catch (there always is):
<p>You should comment into your Class which trigger is calling the class because otherwise, it is almost impossible to see at a glance where the code flows.  This will especially help when writing and debugging tests.
<p>Just a matter of personal style: It may be a good idea to write an Apex Class for each object's triggers (such as class AccountTriggers above).  Code reuse is still possible, but it can track where triggers were originally used.
<p>Happy coding!]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2009/05/18/pulling-code-out-of-triggers.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Hacking a Case Comment Trigger</title>
		<link>http://www.x2od.com/2009/04/01/hacking-a-case-comment-trigger.html</link>
		<comments>http://www.x2od.com/2009/04/01/hacking-a-case-comment-trigger.html#comments</comments>
		<pubDate>Wed, 01 Apr 2009 20:01:23 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Force.com Builder]]></category>
		<category><![CDATA[Force.com Platform]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=477</guid>
		<description><![CDATA[There has been some chatter about asking the salesforce.com team to include the CaseComment object in the "triggerable" list.  After conferring with JP Seabury (ForceMonkey), we designed a Rube Goldberg-esque solution to the problem.  ]]></description>
			<content:encoded><![CDATA[<p>There has been some discussion about asking the salesforce.com team to include the CaseComment object in the &#8220;triggerable&#8221; list.  After conferring with JP Seabury (<a href="http://forcemonkey.blogspot.com">ForceMonkey</a>), we designed a Rube Goldberg-esque solution to the problem.<br />
<span id="more-477"></span><br />
<big><b>Business Use-Case</b></big><br />
Whenever a user adds a comment to a case, add him/her to the Case Team.</p>
<h3>The Plan</h3>
<p>Here it is, in general terms:</p>
<ol>
<li>Workflow on <code>Case Comment</code> sends email to Apex email service</li>
<li>Email service parses <code>CaseId</code> and <code>UserId</code> and adds the User to the Case Team
</ol>
<p><big><b>Case Comment Workflow</b></big><br />
Use existing workflow functionality to send an email whenever a comment is added to a case.</p>
<ul>
<li>Template Includes:</li>
<li>Case Id</li>
<li>User Id</li>
</ul>
<p>The recipient is an Apex email service that we can code using the <a href="http://blog.sforce.com/sforce/2008/06/create-ideas-fr.html">Email to Idea</a> example by Rasmus Mencke.<br />
For more information on setting up the <a href="http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_email_inbound_using.htm"><code>InboundEmail object</code></a>, check the <a href="http://www.salesforce.com/us/developer/docs/apexcode/index.htm">Apex documentation</a>.<br />
<big><b>Apex Class</b></big><br />
The class needs to add the User to the Case Team, which requires a few fields:</p>
<ul>
<li><code>MemberId</code> &#8211; UserId (received from the email)</li>
<li><code>ParentId</code> &#8211; CaseId (received from the email)</li>
<li><code>TeamRoleId</code> &#8211; Could be hardcoded or found in a SOQL SELECT statement. A better practice would be to pass the name or <code>Id</code> in the email (coding it in the template), allowing the use of one Apex Class with multiple Case workflow email templates.</li>
<li><strong>NOT</strong> <code>TeamTemplateMemberId</code> &#8211; This is not a createable field. It is only available when Case Team members are added automatically in Salesforce CRM.</li>
</ul>
<p>That&#8217;s it!  The unique part of this is that we&#8217;re sending an email FROM Salesforce TO Salesforce.<br />
Thinking outside the box &#8211; isn&#8217;t it more fun?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2009/04/01/hacking-a-case-comment-trigger.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Flexible Field Labels</title>
		<link>http://www.x2od.com/2009/03/23/flexible-field-labels.html</link>
		<comments>http://www.x2od.com/2009/03/23/flexible-field-labels.html#comments</comments>
		<pubDate>Mon, 23 Mar 2009 21:02:46 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Native Application]]></category>
		<category><![CDATA[Visualforce]]></category>
		<category><![CDATA[salesforce.com]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[Force.com Platform]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=439</guid>
		<description><![CDATA[While making a Visualforce page to display a Zip/Country -> City, State, County application, it became obvious that labeling fields manually will not satisfy all users, especially international ones. There are a few ways to include a field and its label on a Visualforce page. The simplest, using OutputField: VF Page (simple): &#60;apex:page standardcontroller=&#34;Account&#34;&#62; &#60;apex:pageblock&#62; [...]]]></description>
			<content:encoded><![CDATA[While making a Visualforce page to display a Zip/Country -> City, State, County application, it became obvious that labeling fields manually will not satisfy all users, especially international ones.  

There are a few ways to include a field and its label on a Visualforce page.  

<span id="more-439"></span>
<p>The simplest, using OutputField:<br>
<strong>VF Page (simple):</strong>
<pre class="brush: xml;">
&lt;apex:page standardcontroller=&quot;Account&quot;&gt;
&lt;apex:pageblock&gt;
&lt;apex:pageblocksection&gt;
&lt;apex:outputField value=&quot;{!Account.Name}&quot; /&gt;
&lt;/apex:pageblocksection&gt;
&lt;/apex:pageblock&gt;
&lt;/apex:page&gt;
</pre>

<a href="http://www.x2od.com/2009/03/23/flexible-field-labels.html/code1" rel="attachment wp-att-451"><img src="http://www.x2od.com/wp/uploads/code1.png" alt="code1" title="code1" width="386" height="57" class="aligncenter size-full wp-image-451" /></a><p><p>

The most common (based on code shares and other observations) method allows one to use a label other than the one in Salesforce.  It also allows combining of multiple fields while maintaining the standard style:<br>
<strong>VF Page (common, but static):</strong>
<pre class="brush: xml;">
&lt;apex:page standardcontroller=&quot;Account&quot;&gt;
&lt;apex:pageblock&gt;
&lt;apex:pageblocksection columns=&quot;1&quot;&gt;
&lt;apex:pageblocksectionitem&gt;
&lt;apex:outputLabel value=&quot;Account Name&quot; for=&quot;an&quot; /&gt;
&lt;apex:outputText value=&quot;{!Account.Name}&quot; id=&quot;an&quot; /&gt;
&lt;/apex:pageblocksectionitem&gt;
&lt;apex:pageblocksectionitem&gt;
&lt;apex:outputLabel value=&quot;City, State, Zip&quot; for=&quot;csz&quot; /&gt;
&lt;apex:outputText value=&quot;{!Account.BillingCity}, {!Account.BillingState} {!Account.BillingPostalCode}&quot; /&gt;
&lt;/apex:pageblocksectionitem&gt;
&lt;/apex:pageblocksection&gt;
&lt;/apex:pageblock&gt;
&lt;/apex:page&gt;
</pre>

<a href="http://www.x2od.com/2009/03/23/flexible-field-labels.html/code2" rel="attachment wp-att-450"><img src="http://www.x2od.com/wp/uploads/code2.png" alt="code2" title="code2" width="401" height="99" class="aligncenter size-full wp-image-450" /></a><p><p>

And a way to allow field label renaming and translations:<br>
<strong>VF Page (more flexible, allowing for renaming and translations):</strong>
<pre class="brush: xml;">
&lt;apex:page standardcontroller=&quot;Account&quot;&gt;
&lt;apex:pageblock&gt;
&lt;apex:pageblocksection columns=&quot;1&quot;&gt;
&lt;apex:pageblocksectionitem&gt;
&lt;apex:outputLabel value=&quot;{!$ObjectType.account.fields.name.label}&quot;  for=&quot;an&quot; /&gt;
&lt;apex:outputText value=&quot;{!Account.Name}&quot; id=&quot;an&quot; /&gt;
&lt;/apex:pageblocksectionitem&gt;
&lt;apex:pageblocksectionitem&gt;
&lt;apex:outputLabel value=&quot;{!$ObjectType.account.fields.billingcity.label}, {!$ObjectType.account.fields.billingstate.label}, {!$ObjectType.account.fields.billingpostalcode.label}&quot; for=&quot;csz&quot; /&gt;
&lt;apex:outputText value=&quot;{!Account.BillingCity}, {!Account.BillingState} {!Account.BillingPostalCode}&quot; id=&quot;csz&quot;/&gt;
&lt;/apex:pageblocksectionitem&gt;
&lt;/apex:pageblocksection&gt;
&lt;/apex:pageblock&gt;
&lt;/apex:page&gt;
</pre>

<a href="http://www.x2od.com/2009/03/23/flexible-field-labels.html/code3" rel="attachment wp-att-449"><img src="http://www.x2od.com/wp/uploads/code3.png" alt="code3" title="code3" width="413" height="106" class="aligncenter size-full wp-image-449" /></a><p><p><p>
So by using <strong>$ObjectType.account.fields.billingcity.label</strong> (and similar markup for other objects and fields) we can allow org-specific customizations to come into our code with no effort required.
<p>
There's a catch (there always is).  Note that there is no way to combine the three fields for City, State, and Zip (while using automatic renaming to help us with any customizations that the org has made) while maintaining proper labeling.  In this case, the label for the combined field would be "<strong>Billing City, Billing State, Billing Zip/PostalCode</strong>."  In other words, we can use whatever the org prefers for each field, but the developer must choose the label, which must remain static.<p>
The more astute administrators and developers will note that there is a solution available: Use a component and pass the field labels displayed to the component.  Then, using custom labels and translations, the component could be made truly international.  This is, however, beyond the scope of this post.  But it is an idea for a future post...<p>
And the most astute amongst you are probably saying, "A truly flexible labeling system would allow the word "State" for a US address, "Province" for Canadian and others, and would still be completely customizable and translatable.  Yes, that would be nice.  :)]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2009/03/23/flexible-field-labels.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Developer Preview Releases for the Google Visualization API</title>
		<link>http://www.x2od.com/2009/02/21/google-developer-preview-visualization-api.html</link>
		<comments>http://www.x2od.com/2009/02/21/google-developer-preview-visualization-api.html#comments</comments>
		<pubDate>Sat, 21 Feb 2009 19:55:18 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[New Features]]></category>
		<category><![CDATA[Winter 09]]></category>
		<category><![CDATA[salesforce.com]]></category>
		<category><![CDATA[Dreamforce]]></category>
		<category><![CDATA[Eclipse IDE]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=373</guid>
		<description><![CDATA[Google has invited developers to participate in Developer Preview Releases for the Visualization API]]></description>
			<content:encoded><![CDATA[<p>Dreamforce 2008 brought many exciting new features from salesforce.com, both on the CRM/front-end side and the Force.com platform/back-end side.  One of the favorites was the announcement that salesforce.com had released a <a href="http://code.google.com/apis/visualization/">Google Visualization</a> <a href="http://developer.force.com/codeshare/apex/projectpage?id=a06300000030w9LAAQ">code share project</a>.  Google has invited developers to participate in <a href='http://google-code-updates.blogspot.com/2009/02/developer-preview-releases-for.html'>Developer Preview Releases for the Visualization API</a>.</p>
<p>It looks like a pretty cool way to work on <a href="http://wiki.apexdevnet.com/index.php/Force.com_Zillow_Mashup">RESTful</a> integrations while making some pretty pictures for your users.</p>
<p>For those unfamiliar with the Salesforce/Google Visualization toolkit, developer.force.com has a <a href="http://wiki.apexdevnet.com/index.php/Google_Visualizations">great introduction</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2009/02/21/google-developer-preview-visualization-api.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubiquity Plugin for developer.force.com</title>
		<link>http://www.x2od.com/2009/02/05/ubiquity-plugin-for-developerforce.html</link>
		<comments>http://www.x2od.com/2009/02/05/ubiquity-plugin-for-developerforce.html#comments</comments>
		<pubDate>Thu, 05 Feb 2009 20:34:18 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[Just for fun]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[X-Squared On Demand]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=326</guid>
		<description><![CDATA[Inspired by Gina Tripani's release of a Ubiquity plug-in to search Lifehacker via Google, I used her code as a base (thanks, Gina) and created a Ubiquity plug-in to search developer.force.com.]]></description>
			<content:encoded><![CDATA[<p>Inspired by <a href="http://ginatrapani.org">Gina Trapani&#8217;s</a> release of a <a href="http://ginatrapani.org/workshop/ubiquity/lifehacker-search.xhtml">Ubiquity plug-in</a> to search <a href="http://lifehacker.com">Lifehacker</a> via Google, I used her code as a base (thanks, Gina) and created a <a href="http://www.x2od.com/projects/ubiquity/index.xhtml">Ubiquity plug-in to search developer.force.com</a>.</p>
<p>Because <a href="http://developer.force.com">developer<em>f</em>orce</a> uses Google&#8217;s technology to search its own site, I wanted to display the search results within the developer.force.com site instead of using Google to search.  This meant that I could not (in version 1) display results as the user types in a word.  It is still a timesaver, though, as it opens the site and executes the search all-at-once.</p>
<p>To install the plug-in, make sure you have <a href="http://labs.mozilla.com/projects/ubiquity/">Ubiquity</a> installed in Firefox, and then go to the project homeage at <a href="http://www.x2od.com/projects/ubiquity/index.xhtml">http://www.x2od.com/projects/ubiquity/index.xhtml</a>.  Install and you&#8217;re done!  For more tips on using Ubiquity, visit <a href="http://lifehacker.com/5145709/make-ubiquity-your-ultimate-firefox-commander?skyline=true&#038;s=i">Lifehacker</a>.</p>
<p><a href="http://www.x2od.com/projects/ubiquity/index.xhtml"><img alt="" src="http://www.x2od.com/projects/ubiquity/developerforce-ubiquity-search-screenshot.png" title="Developerforce Ubiquity Search Screenshot" class="aligncenter" width="537" height="159" /></a><br />
<br clear="both" /><br />
Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2009/02/05/ubiquity-plugin-for-developerforce.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Ultimate Visualforce Events Tab &#8211; Almost</title>
		<link>http://www.x2od.com/2009/01/05/the-ultimate-visualforce-events-tab-almos.html</link>
		<comments>http://www.x2od.com/2009/01/05/the-ultimate-visualforce-events-tab-almos.html#comments</comments>
		<pubDate>Mon, 05 Jan 2009 16:35:56 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Visualforce]]></category>
		<category><![CDATA[Winter 09]]></category>
		<category><![CDATA[salesforce.com]]></category>
		<category><![CDATA[Apex]]></category>
		<category><![CDATA[Force.com Builder]]></category>
		<category><![CDATA[Force.com Platform]]></category>
		<category><![CDATA[Salesforce.com]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=217</guid>
		<description><![CDATA[Check old blog posts, and you&#8217;ll see that I&#8217;ve been working on custom Events and Task tabs for a while now. A Task Visualforce tab (that mimics the Task box on the Home Page) is almost ready to come out, but the Events Enhanced List tab is (pretty much) here! This bears emphasizing: Enhanced Lists [...]]]></description>
			<content:encoded><![CDATA[Check old blog posts, and you&#8217;ll see that I&#8217;ve been working on custom Events and Task tabs for a while now.  A Task Visualforce tab (that mimics the Task box on the Home Page) is almost ready to come out, but the Events Enhanced List tab is (pretty much) here!<p>
This bears emphasizing: Enhanced Lists were initially not fully released for Activity/Event/Task objects, but are available now.  <p>
The code is ridiculously simple, thanks to the apex:EnhancedList Visualforce tag:
<pre class="brush: xml;">
&lt;apex:page standardController=&quot;Task&quot; &gt;
&lt;apex:enhancedList type=&quot;Activity&quot; height=&quot;800&quot; rowsPerPage=&quot;50&quot; /&gt;
&lt;/apex:page&gt;
</pre>

See?  Nothing to it!   Or so we thought.  There are some catches (there always are):<p>

<ol>
	<li>The original use-case required displaying all upcoming events without the header or sidebar.  We still cannot do this.  Quoting from the Winter &#8217;09 Release Notes: <em>The enhancedList component is not allowed on pages that have the attribute showHeader set to false.</em></li>
	<li>We&#8217;d like to create a custom tab for this page.  We create a Visualforce Tab, pick a custom icon, and show the page&#8230; and when I click on the tab, the enhanced list is displayed, but the tab is not highlighted.  Also, the custom icon I chose is not displayed.  How do we highlight our tab?<br />
After making the page, we make the tab as desribed above.  Then we RETURN to the page and add a tabstyle modifier to the apex:page tag, like so:

<pre class="brush: xml;">
&lt;apex:page standardController=&quot;Task&quot; tabstyle=&quot;enhanced_activities__tab&quot;&gt;
&lt;apex:enhancedList type=&quot;Activity&quot; height=&quot;800&quot; rowsPerPage=&quot;50&quot; /&gt;
&lt;/apex:page&gt;
</pre>
[Of course, change the tab name to whatever you choose.]<p>

Success?  Not quite.  There&#8217;s another catch:

</li>
	<li>The tab is highlighted (brown in our case), but the color and icon for the enhanced list are standard green/home.  <br />

Sadly, I have no workaround for this one. Sorry.</li>
</ol>

To repeat: Enhanced lists were not initially fully available for Events and Tasks, but now do support them.  <p>

Moving forward, consider if you want to create a particular enhanced list view instead of calling the standard enhanced Activity list as I have done here.  If you would prefer to make a custom enhanced list view, then you will need to add more code, but that is beyond the scope of this post.<p>

Enjoy!]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2009/01/05/the-ultimate-visualforce-events-tab-almos.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Force.com Sites Guest User Profile Permissions</title>
		<link>http://www.x2od.com/2008/12/22/sites-guest-profile.html</link>
		<comments>http://www.x2od.com/2008/12/22/sites-guest-profile.html#comments</comments>
		<pubDate>Mon, 22 Dec 2008 16:54:39 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Native Application]]></category>
		<category><![CDATA[New Features]]></category>
		<category><![CDATA[Winter 09]]></category>
		<category><![CDATA[Force.com Platform]]></category>
		<category><![CDATA[Sites]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=294</guid>
		<description><![CDATA[I&#8217;m working on an event registration application for the Sites Developer Challenge, and it involves a validation that the registrant&#8217;s email exists in a Contact record. Remembering that Steve Andersen had run into some obstacles with Contact.Email visibility, I decided to check the guest profile for Contact Field Level Security. Here&#8217;s what I found: If [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on an event registration application for the <a href="http://developer.force.com/developerchallenge">Sites Developer Challenge</a>, and it involves a validation that the registrant&#8217;s email exists in a Contact record.  Remembering that <a href="http://community.salesforce.com/sforce/board/message?message.uid=96974#U96974">Steve Andersen had run into some obstacles</a> with Contact.Email visibility, I decided to check the guest profile for Contact Field Level Security.  Here&#8217;s what I found:</p>
<div id="attachment_295" class="wp-caption alignnone" style="width: 521px"><img src="http://www.x2od.com/wp/uploads/sitesguestcontactfls.jpg" alt="Guest profile Contact Field Level Security" title="sitesguestcontactfls" width="50%" height="50%" class="size-full wp-image-295" /><p class="wp-caption-text">Guest profile Contact Field Level Security</p></div>
<p>If you squint a bit, you can see that the Opt-Out and Email fields are hidden to the guest user.  I have no idea why these, in particular, are hidden.  Likewise, I couldn&#8217;t find a pattern in which fields were shown on the custom objects I had created, nor which were visible on standard objects.</p>
<p>In any event, I don&#8217;t have any pearls of wisdom on this topic; this is more of an informative note to all that are using Sites (especially if you plan to do any communication-subscriptions) to check out the Field-Level Security.</p>
<p>For those wondering how to get to this Profile (since it is not visible in the usual Profile section), go to the Sites page > Site Name or URL > Public Access Settings (a button).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2008/12/22/sites-guest-profile.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inline Visualforce Page Layouts!</title>
		<link>http://www.x2od.com/2008/11/29/inline-visualforce-page-layouts.html</link>
		<comments>http://www.x2od.com/2008/11/29/inline-visualforce-page-layouts.html#comments</comments>
		<pubDate>Sat, 29 Nov 2008 23:42:20 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Native Application]]></category>
		<category><![CDATA[New Features]]></category>
		<category><![CDATA[salesforce.com]]></category>
		<category><![CDATA[Force.com Builder]]></category>
		<category><![CDATA[New Developments]]></category>
		<category><![CDATA[Visualforce]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=269</guid>
		<description><![CDATA[We're all used to using inline S-Controls, dragging and dropping them into page layouts.  And the entire Salesforce community has been spending tons of time recreating page layouts in Visualforce, just to edit one small piece of a page.

As an example, how would you implement the example at developer.force.com: <a href="http://wiki.apexdevnet.com/index.php/Visualforce_DynamicEditPage">Visualforce Dynamic Edit Page</a>?  You would do it the way it was explained in the blog post!

Well the rules of the game have changed.]]></description>
			<content:encoded><![CDATA[<p><strong><a href="http://blog.sforce.com/sforce/2008/11/adding-a-visualforce-page-to-a-page-layout.html">This is huge news!</a></strong></p>
<p>We&#8217;re all used to using inline S-Controls, dragging and dropping them into page layouts.  And the entire Salesforce community has been spending tons of time recreating page layouts in Visualforce, just to edit one small piece of a page.</p>
<p>As an example, how would you implement the example at developer.force.com: <a href="http://wiki.apexdevnet.com/index.php/Visualforce_DynamicEditPage">Visualforce Dynamic Edit Page</a>?  You would do it the way it was explained in the blog post!</p>
<p>Well the rules of the game have changed.</p>
<p>As long as you use a Standard Controller, <a href="http://blog.sforce.com/sforce/2008/11/adding-a-visualforce-page-to-a-page-layout.html"><strong>you can now place Visualforce pages IN regular page layouts</strong></a>!</p>
<div class="wp-caption alignnone" style="width: 510px"><img width=497 height=309 alt="Inline Visualforce Page Layout screenshot" src="http://blog.sforce.com/.a/6a00d8341cded353ef0105361c5757970b-pi" title="Inline Visualforce Page Layout" width="829" height="515" /><p class="wp-caption-text">Inline Visualforce Page Layout screenshot</p></div>
<p>The article was written by Sati Hillyear, who is also an expert on the License Manager Application.  Check it out!</p>
<p>[<em>Addendum 5-9-2009:</em> For another example of this, see <a href="http://blog.jeffdouglas.com/2009/05/08/inline-visualforce-pages-with-standard-page-layouts/">Jeff Douglas' blog post</a>.]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2008/11/29/inline-visualforce-page-layouts.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Project: Change Owner Button in Visualforce</title>
		<link>http://www.x2od.com/2008/11/13/project-change-owner-button-in-visualforce.html</link>
		<comments>http://www.x2od.com/2008/11/13/project-change-owner-button-in-visualforce.html#comments</comments>
		<pubDate>Thu, 13 Nov 2008 06:13:15 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Visualforce]]></category>
		<category><![CDATA[X-Squared On Demand]]></category>
		<category><![CDATA[salesforce.com]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=244</guid>
		<description><![CDATA[Drawing upon some code I found in the Developers Guide, I have written a Visualforce page to mass-change the owner of all selected records to any active User in Salesforce.  Yes, it only works with Contacts for now, but my next step will be to use Dynamic Apex to pass the sObject name to the page and its extension/controller, allowing me to reuse one bit of code for multiple objects.  We'll see how it goes.  But in the meantime, enjoy this page that lets you perform a search, check which records you want to transfer, and then input a User.  I've tested it with 50 records at once, so that should suffice for most uses.]]></description>
			<content:encoded><![CDATA[<p>Salesforce Labs has put out a series of Mass Action packages on the AppExchange.  There is <a href="https://www.salesforce.com/appexchange/detail_overview.jsp?NavCode__c=&#038;id=a0330000000iAkcAAE">Mass Transfer Opportunity Owner</a> (uses AJAX), <a href="http://www.salesforce.com/appexchange/detail_overview.jsp?NavCode__c=&#038;id=a0330000000iIEtAAM">Mass Update Contact Addresses</a> (AJAX), <a href="http://www.salesforce.com/appexchange/detail_overview.jsp?NavCode__c=&#038;id=a0330000000iAkcAAE">Mass Update Opportunity Owner</a>, <a href="https://www.salesforce.com/appexchange/detail_overview.jsp?NavCode__c=&#038;id=a0330000000iIAxAAM">Mass Update Opportunity Close Dates</a>, etc.  All of these are &#8220;thick client&#8221; tools, meaning that data must be loaded onto your computer, altered, and then uploaded back to Salesforce.  </p>
<p><a href="http://community.salesforce.com/sforce/tracker?user.id=198">Ron Hess</a> released a super bit of code, found in the Visualforce documentation and elsewhere, to <a href="http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_sosc_custom_button.htm">Mass Update Opportunity Stage and Close Date</a>.  It could, theoretically, be expanded to other fields as well.  This got me thinking about doing so with other objects.  </p>
<p>A while ago, I took the code for the <a href="http://www.salesforce.com/appexchange/detail_overview.jsp?NavCode__c=&#038;id=a03300000033CsnAAE">Mass Delete</a> button and altered it to change the owner of the selected records to the User clicking the button.  It was like an Accept button, but I could use it for any object.  Actually, it wasn&#8217;t as easy as that.  I had to make one button for each object, and maintenance was a pain&#8211;whenever I created a new object, I needed to clone my code.</p>
<p>Drawing upon some code I found in the <a href="http://wiki.apexdevnet.com/index.php/force_library">Developers Guide</a>, I have written a Visualforce page to mass-change the owner of all selected records to any active User in Salesforce.  Yes, it only works with Contacts for now, but my next step will be to use Dynamic Apex to pass the sObject name to the page and its extension/controller, allowing me to reuse one bit of code for multiple objects.  We&#8217;ll see how it goes.  But in the meantime, enjoy this page that lets you perform a search, check which records you want to transfer, and then input a User.  I&#8217;ve tested it with 50 records at once, so that should suffice for most uses.</p>
<p><strong>VF Page:</strong><br />
<pre class="brush: xml;">&lt;br /&gt;
&lt;apex:page standardController=&quot;Contact&quot; recordSetVar=&quot;Contacts&quot; id=&quot;updateOwnerPage&quot;&gt;&lt;br /&gt;
&lt;apex:form&gt;&lt;br /&gt;
&lt;apex:sectionHeader title=&quot;Change Owner for Contacts&quot;/&gt;&lt;br /&gt;
&lt;apex:pageBlock mode=&quot;edit&quot;&gt;&lt;br /&gt;
&lt;apex:pageMessages /&gt;&lt;br /&gt;
&lt;apex:pageblockSection title=&quot;Change&quot; columns=&quot;1&quot;&gt;&lt;br /&gt;
&lt;apex:pageblockSectionItem &gt;&lt;br /&gt;
&lt;apex:outputLabel for=&quot;owner&quot;&gt;New Owner&lt;/apex:outputLabel&gt;&lt;br /&gt;
&lt;apex:inputField id=&quot;owner&quot; value=&quot;{!Contact.OwnerId}&quot;/&gt;&lt;br /&gt;
&lt;/apex:pageblockSectionItem&gt;&lt;br /&gt;
&lt;/apex:pageBlockSection&gt;&lt;br /&gt;
&lt;apex:pageBlockSection title=&quot;Selected Contacts&quot; columns=&quot;1&quot;&gt;&lt;br /&gt;
&lt;apex:pageBlockTable value=&quot;{!selected}&quot; var=&quot;j&quot; bgcolor=&quot;#F3F3EC&quot; width=&quot;100%&quot;&lt;br /&gt;
styleClass=&amp;#8221;list&amp;#8221; rowClasses=&amp;#8221;dataRow&amp;#8221; onRowMouseOver=&amp;#8221;hiOn(this);&amp;#8221; onRowMouseOut=&amp;#8221;hiOff(this);&amp;#8221;&gt;&lt;br /&gt;
&lt;apex:column &gt;&lt;br /&gt;
&lt;apex:facet name=&quot;header&quot;&gt;Contact Name&lt;/apex:facet&gt;&lt;br /&gt;
&lt;apex:outputLink value=&quot;{!URLFOR($Action.Contact.View, j.id)}&quot;&gt;&lt;br /&gt;
{!j.FirstName} {!j.LastName}&lt;/apex:outputLink&gt;&lt;br /&gt;
&lt;/apex:column&gt;&lt;br /&gt;
&lt;apex:column &gt;&lt;br /&gt;
&lt;apex:facet name=&quot;header&quot;&gt;Account Name&lt;/apex:facet&gt;&lt;br /&gt;
&lt;apex:outputLink value=&quot;{!URLFOR($Action.Account.View, j.Account.id)}&quot;&gt;&lt;br /&gt;
{!j.Account.Name}&lt;/apex:outputLink&gt;&lt;br /&gt;
&lt;/apex:column&gt;&lt;br /&gt;
&lt;apex:column&gt;&lt;br /&gt;
&lt;apex:facet name=&quot;header&quot;&gt;Current Owner&lt;/apex:facet&gt;&lt;br /&gt;
{!j.Owner.Name}&lt;br /&gt;
&lt;/apex:column&gt;&lt;br /&gt;
&lt;/apex:pageBlockTable&gt;&lt;br /&gt;
&lt;/apex:pageblockSection&gt;&lt;br /&gt;
&lt;apex:pageBlockButtons location=&quot;bottom&quot;&gt;&lt;br /&gt;
&lt;apex:commandButton value=&quot;Save&quot; action=&quot;{!save}&quot;/&gt;&lt;br /&gt;
&lt;apex:commandButton value=&quot;Cancel&quot; action=&quot;{!cancel}&quot;/&gt;&lt;br /&gt;
&lt;/apex:pageBlockButtons&gt;&lt;br /&gt;
&lt;/apex:pageBlock&gt;&lt;br /&gt;
&lt;/apex:form&gt;&lt;br /&gt;
&lt;/apex:page&gt;&lt;br /&gt;
</pre></p>
<p><strong>Button:</strong><br />
Go to Setup -> Contact -> Buttons and Links<br />
Create a new button, set it to execute in the current window with sidebar and header, and set it to call a Visualforce page.  Select the page you just created.  Then add the button to Contact Search Layout and to any Contact related lists you like.</p>
<p>Voila!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2008/11/13/project-change-owner-button-in-visualforce.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project: Lookup to Picklist</title>
		<link>http://www.x2od.com/2008/11/11/project-lookup-to-picklist.html</link>
		<comments>http://www.x2od.com/2008/11/11/project-lookup-to-picklist.html#comments</comments>
		<pubDate>Tue, 11 Nov 2008 05:56:37 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Visualforce]]></category>
		<category><![CDATA[salesforce.com]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Dreamforce]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[X-Squared On Demand]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=232</guid>
		<description><![CDATA[In the first installment of post-Dreamforce projects, I present a mechanism to present the user with all available Lookup options in a picklist. This should simplify some Visualforce pages. (Credit to the Developers Guide from the new post-Dreamforce Library.) The key to the code is the ability to customize the SOQL statement to focus as [...]]]></description>
			<content:encoded><![CDATA[<p>In the first installment of post-Dreamforce projects, I present a mechanism to present the user with all available Lookup options in a picklist.  This should simplify some Visualforce pages.  (Credit to the <a href="http://wiki.apexdevnet.com/index.php/force_library">Developers Guide</a> from the new post-Dreamforce Library.)</p>
<p>The key to the code is the ability to customize the SOQL statement to focus as much, or as little, as the developer would like.  Though the code I provide makes no limit on the number of records returned, I encourage developers to limit the select statement as seen fit.</p>
<p><strong>VF Page:</strong><br />
<pre class="brush: xml;">&lt;br /&gt;
&lt;apex:page standardcontroller=&quot;Child__c&quot; Extensions=&quot;ChildExtension&quot;&gt;&lt;br /&gt;
&lt;apex:messages &gt;&lt;/apex:messages&gt;&lt;br /&gt;
&lt;apex:form &gt;&lt;br /&gt;
&lt;apex:pageBlock mode=&quot;edit&quot; id=&quot;thePageBlock&quot;&gt;&lt;br /&gt;
&lt;apex:pageBlockButtons &gt;&lt;br /&gt;
&lt;apex:commandButton value=&quot;Save&quot; action=&quot;{!save}&quot;/&gt;&lt;br /&gt;
&lt;apex:commandButton value=&quot;Cancel&quot; action=&quot;{!cancel}&quot;/&gt;&lt;br /&gt;
&lt;/apex:pageBlockButtons&gt;&lt;br /&gt;
&lt;apex:pageblockSection id=&quot;ParentList&quot; title=&quot;1&quot;&gt;&lt;br /&gt;
&lt;apex:pageBlockSectionItem &gt;&lt;br /&gt;
&lt;apex:outputLabel value=&quot;Parent&quot; for=&quot;p&quot;/&gt;&lt;br /&gt;
&lt;apex:selectList id=&quot;p&quot; value=&quot;{!Child__c.Parent__c}&quot; size=&quot;1&quot; title=&quot;3&quot;&gt;&lt;br /&gt;
    &lt;apex:selectOptions value=&quot;{!ParentOptions}&quot;/&gt;&lt;br /&gt;
&lt;/apex:selectList&gt;&lt;br /&gt;
&lt;/apex:pageBlockSectionItem&gt;&lt;br /&gt;
&lt;/apex:pageblocksection&gt;&lt;br /&gt;
&lt;/apex:pageBlock&gt;&lt;br /&gt;
&lt;/apex:form&gt;&lt;br /&gt;
&lt;/apex:page&gt;&lt;br /&gt;
</pre></p>
<p><strong>Extension:</strong><br />
Note the SOQL query in Line 12 (below) that defines which records are included in the picklist.  You can include WHERE and LIMIT statements to get the picklist down to a manageable number of items.</p>
<p><pre class="brush: java;">&lt;br /&gt;
public class ChildExtension {&lt;/p&gt;
&lt;p&gt;private final Child__c child;&lt;/p&gt;
&lt;p&gt;    public ChildExtension(ApexPages.StandardController controller) {&lt;br /&gt;
        this.child = (Child__c)controller.getRecord();&lt;br /&gt;
        }&lt;/p&gt;
&lt;p&gt;    public List&lt;br /&gt;
&lt;selectOption&gt; PositionOptions {get&lt;br /&gt;
        {&lt;br /&gt;
        List&lt;br /&gt;
&lt;selectOption&gt; parents = new List&lt;br /&gt;
&lt;selectOption&gt;();&lt;br /&gt;
        for (Parent__c prt : [select name from Parent__c pt])&lt;br /&gt;
            parents.add(new selectOption(prt.id, prt.name));&lt;br /&gt;
            return parents;&lt;br /&gt;
        }&lt;br /&gt;
    private set;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
</pre></p>
<p>Because the parents List in the extension sends an ID to the application, it can successfully create a record with the parent Name in the picklist, but the ID in the background.  You can also substitute a different field for Name: If you prefer, put a contact&#8217;s email address or anything else.  Try it out!  </p>
<p>One more thing: This is an easy segue into another project, which will be a way to use the traditional lookup interface but to pre-filter the records available in the lookup.</p>
<p>And because I put this in every post: There&#8217;s a catch.  (There always is.)  I&#8217;m sure that somewhere in there, Salesforce would prefer that we not create a picklist of a few hundred items.  So please feel free to test the limits of this visualforce method, but please be prepared to filter your SOQL query.</p>
<p>On a separate note, I just had lunch with <a href="http://theenforcer.net">John Rotenstein aka The Enforcer</a>, who already put up a <a href="http://theenforcer.net/2008/11/x2od-the-enforcer/">photo</a> of our time in his office.  (I think the pirate logo was an accident, but it does add to my sinister persona, no?)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2008/11/11/project-lookup-to-picklist.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Salesforce Order of Execution</title>
		<link>http://www.x2od.com/2008/11/09/salesforce-order-of-execution.html</link>
		<comments>http://www.x2od.com/2008/11/09/salesforce-order-of-execution.html#comments</comments>
		<pubDate>Sun, 09 Nov 2008 09:25:43 +0000</pubDate>
		<dc:creator>David Schach</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Native Application]]></category>
		<category><![CDATA[Apex]]></category>
		<category><![CDATA[Force.com Builder]]></category>

		<guid isPermaLink="false">http://www.x2od.com/?p=230</guid>
		<description><![CDATA[I came across this page in the Apex documentation and wanted to share it with everyone.  So many people have asked about this in the past, so it seems a good idea to publicize it:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm]]></description>
			<content:encoded><![CDATA[<p>I came across this page in the Apex documentation and wanted to share it with everyone.  So many people have asked about this in the past, so it seems a good idea to publicize it:</p>
<p><a href="http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm">http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm</a></p>
<p><strong>Triggers and Order of Execution</strong></p>
<p>When a record is saved with an insert, update, or upsert statement, the following events occur in order:</p>
<p>   1. The original record is loaded from the database (or initialized for an insert statement)<br />
   2. The new record field values are loaded from the request and overwrite the old values<br />
   3. All before triggers execute<br />
   4. System validation occurs, such as verifying that all required fields have a non-null value, and running any user-defined validation rules<br />
   5. The record is saved to the database, but not yet committed<br />
   6. All after triggers execute<br />
   7. Assignment rules execute<br />
   8. Auto-response rules execute<br />
   9. Workflow rules execute<br />
  10. If there are workflow field updates, the record is updated again<br />
  11. If the record was updated with workflow field updates, before and after triggers fire one more time (and only one more time)<br />
  12. Escalation rules execute<br />
  13. All DML operations are committed to the database<br />
  14. Post-commit logic executes, such as sending email</p>
<p><strong>Additional Considerations</strong></p>
<p>Please note the following when working with triggers:</p>
<p>    * When Enable Validation and Triggers from Lead Convert is selected, if the lead conversion creates an opportunity and the opportunity has Apex before triggers associated with it, the triggers run immediately after the opportunity is created, before the opportunity contact role is created. For more information, see &#8220;Customizing Lead Settings&#8221; in the Salesforce online help.<br />
    * If you are using before triggers to set Stage and Forecast Category for an opportunity record, the behavior is as follows:<br />
          o If you set Stage and Forecast Category, the opportunity record contains those exact values.<br />
          o If you set Stage but not Forecast Category, the Forecast Category value on the opportunity record defaults to the one associated with trigger Stage.<br />
          o If you reset Stage to a value specified in an API call or incoming from the user interface, the Forecast Category value should also come from the API call or user interface. If no value for Forecast Category is specified and the incoming Stage is different than the trigger Stage, the Forecast Category defaults to the one associated with trigger Stage. If the trigger Stage and incoming Stage are the same, the Forecast Category is not defaulted.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.x2od.com/2008/11/09/salesforce-order-of-execution.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
