<?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>TehNrd</title>
	<atom:link href="http://www.tehnrd.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tehnrd.com</link>
	<description>Technology - Force.com - jQuery - Life</description>
	<lastBuildDate>Thu, 04 Mar 2010 00:07:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Seattle Force.com Developer Group</title>
		<link>http://www.tehnrd.com/seattle-force-com-developer-group/</link>
		<comments>http://www.tehnrd.com/seattle-force-com-developer-group/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 00:02:44 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Visualforce]]></category>

		<guid isPermaLink="false">http://www.tehnrd.com/?p=551</guid>
		<description><![CDATA[Heads up that if you are a Force.com/Salesforce developer or want to learn more about force.com development in the Seattle area there is a meeting this Thursday, the 4th.
The meetings as always will be held in the West Monroe Partners office located at:
1215 4th Ave, Suite 1010
Seattle, WA 98161
When:  Thursday, March 4th, 2010
Start Time: 4:00 [...]]]></description>
			<content:encoded><![CDATA[<p>Heads up that if you are a Force.com/Salesforce developer or want to learn more about force.com development in the Seattle area there is a meeting this Thursday, the 4th.</p>
<blockquote><p>The meetings as always will be held in the <strong>West Monroe Partners</strong> office located at:</p>
<p>1215 4<sup>th</sup> Ave, Suite 1010</p>
<p>Seattle, WA 98161</p>
<p>When:  Thursday, March 4th, 2010</p>
<p>Start Time: 4:00 PM</p>
<p>This session will be an open forum so bring any questions, problems, and/or issues you have so we can discuss with the group. If we finish early, we can maybe grab a beer at one of the local bars downtown.</p></blockquote>
<p>If you are interested even a little please stop by.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tehnrd.com/seattle-force-com-developer-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>If Computers Could Barf &#8211; Salesforce Debug Log</title>
		<link>http://www.tehnrd.com/if-computers-could-barf-salesforce-debug-log/</link>
		<comments>http://www.tehnrd.com/if-computers-could-barf-salesforce-debug-log/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 16:40:37 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Apex]]></category>

		<guid isPermaLink="false">http://www.tehnrd.com/?p=504</guid>
		<description><![CDATA[This story starts some time ago. I have been complaining about the system/debug log in salesforce.com ever since they released what I would consider version 1.1. You can see my post here, Please fix the Debug Log!, pleading for salesforce to fix the debug log. This was back in July of 2008! From what I [...]]]></description>
			<content:encoded><![CDATA[<p>This story starts some time ago. I have been complaining about the system/debug log in salesforce.com ever since they released what I would consider version 1.1. You can see my post here, <strong><a href="http://community.salesforce.com/sforce/board/message?board.id=apex&#038;message.id=6362" target="_blank">Please fix the Debug Log!</a></strong>, pleading for salesforce to fix the debug log. This was back in July of 2008! From what I can tell there has only been two noticeable changes with this debug log. I will refer to them as version 1.1 which was implemented around the time of the message board post above and the the most recent Spring &#8216;10 incarnation which I will refer to as version 2.0.</p>
<p>I still remember the good old days of the debug log, version 1.0 . Everything was so peachy! Apex was brand new. The debug log output was concise and easy to use. Times where good. Version 1.0 was the best! Sigh&#8230;&#8230; (this is a sigh of fond happy memories). It&#8217;s pretty sad version 1.0 is what I consider to be the best, usually software is supposed to get better with subsequent releases right? Right?!?!? </p>
<p>The clouds became dark (pun intended <img src='http://www.tehnrd.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ) with version 1.1. Now the debug log could log workflow and validation rules! Great! Now my debug logs are incredibly long and full of junk that I rarely, and 99% of the time, never care about when debugging Apex. In orgs that have a lot of workflow rules this makes it terribly painful to do bulk debugging. But Jason, simply set the Log Category to Apex Code and it will only show Apex related output. </p>

<a href="http://www.tehnrd.com/wp-content/gallery/random/logcategory.jpg" title="" class="thickbox" rel="singlepic233" >
	<img class="ngg-singlepic ngg-center" src="http://www.tehnrd.com/wp-content/gallery/cache/233__400x_logcategory.jpg" alt="logcategory" title="logcategory" />
</a>

<p>BWAHAHHAAHHAHA, oh man, that&#8217;s a good one. Up until version 2.0 this had never worked right. It doesn&#8217;t matter what you set the Log Category to as it never outputs what you want it to. </p>
<p>I remember attending the &#8220;Meet the Developers&#8221; session at Dreamforce 09 and hearing the salesforce team say that a new and improved debug log was coming. The room literally roared with applause. I was one of those clapping with excitement. When I finally was able to access the new debug log I was giddy with excitement. Will this be everything I have hoped and dreamed for? Will it save me tons of time? Will it make me a hot breakfast every morning? To my amazement and surprise it has fallen short on nearly all of my expectations. </p>
<p>You can&#8217;t re-size the input box. This was an incredibly useful feature. Why would a useful feature be removed? It makes no sense. Yes, there are work arounds using browser plugins such as Gresemonkey and Stylish but people don&#8217;t want workarounds. They want it to just work.</p>
<p>I may be on a pretty good rant but I have no right to complain if I make no attempt to help improve the tool. I decided to take a stab and building this re-size functionality and it literally took me less than 10 minutes to get a working prototype using jQueryUI. <strong><a href="http://tehnrddemos-developer-edition.na7.force.com/resizableInput" target="_blank">You can check it out here.</a></strong> It is a little rough around the edges but if I can build a working demo this quick there is absolutely no reason salesforce shouldn&#8217;t be able to incorporate this functionality.</p>
<p>The output is also hideous. Perhaps this is the way Java code typically outputs debug logs. I don&#8217;t have enough experience to know. What I do know is this new version makes my life less happy. From a usability perspective the old version was much easier to quickly scan and find what you were looking for. Let&#8217;s compare.</p>
<p>Below I will show the debug outputs for a very simple piece of code. Here is the code:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>Opportunity opp <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>select Id, <span style="color: #003399;">Name</span>, Amount from Opportunity<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	system.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span>opp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>First let&#8217;s look at version 1.1, pre Spring 10.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #cc66cc;">20100210185937.897</span><span style="color: #339933;">:</span>AnonymousBlock<span style="color: #339933;">:</span> line <span style="color: #cc66cc;">1</span>, column <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> SelectLoop<span style="color: #339933;">:</span>LIST<span style="color: #339933;">:</span>SOBJECT<span style="color: #339933;">:</span>Opportunity
<span style="color: #cc66cc;">20100210185937.897</span><span style="color: #339933;">:</span>AnonymousBlock<span style="color: #339933;">:</span> line <span style="color: #cc66cc;">1</span>, column <span style="color: #cc66cc;">23</span><span style="color: #339933;">:</span> SOQL query with <span style="color: #cc66cc;">6</span> rows finished in <span style="color: #cc66cc;">5</span> ms
<span style="color: #cc66cc;">20100210185937.897</span><span style="color: #339933;">:</span>AnonymousBlock<span style="color: #339933;">:</span> line <span style="color: #cc66cc;">2</span>, column <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> Opportunity<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #003399;">Name</span><span style="color: #339933;">=</span>Territory Test, Amount<span style="color: #339933;">=</span><span style="color: #cc66cc;">152989.18</span>, Id<span style="color: #339933;">=</span>00660000008gWE1AAM<span style="color: #009900;">&#125;</span>
<span style="color: #cc66cc;">20100210185937.897</span><span style="color: #339933;">:</span>AnonymousBlock<span style="color: #339933;">:</span> line <span style="color: #cc66cc;">2</span>, column <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> Opportunity<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #003399;">Name</span><span style="color: #339933;">=</span>Pipeline <span style="color: #003399;">Date</span> Test, Amount<span style="color: #339933;">=</span><span style="color: #cc66cc;">5000.00</span>, Id<span style="color: #339933;">=</span>00660000008gpbDAAQ<span style="color: #009900;">&#125;</span>
<span style="color: #cc66cc;">20100210185937.897</span><span style="color: #339933;">:</span>AnonymousBlock<span style="color: #339933;">:</span> line <span style="color: #cc66cc;">2</span>, column <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> Opportunity<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #003399;">Name</span><span style="color: #339933;">=</span>Product Alert Test <span style="color: #cc66cc;">123</span>, Amount<span style="color: #339933;">=</span><span style="color: #cc66cc;">555000.00</span>, Id<span style="color: #339933;">=</span>00660000008gCQ7AAM<span style="color: #009900;">&#125;</span>
<span style="color: #cc66cc;">20100210185937.897</span><span style="color: #339933;">:</span>AnonymousBlock<span style="color: #339933;">:</span> line <span style="color: #cc66cc;">2</span>, column <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> Opportunity<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #003399;">Name</span><span style="color: #339933;">=</span>Giant Product <span style="color: #003399;">List</span>, Amount<span style="color: #339933;">=</span><span style="color: #cc66cc;">0.00</span>, Id<span style="color: #339933;">=</span>00660000009lsB7AAI<span style="color: #009900;">&#125;</span>
<span style="color: #cc66cc;">20100210185937.897</span><span style="color: #339933;">:</span>AnonymousBlock<span style="color: #339933;">:</span> line <span style="color: #cc66cc;">2</span>, column <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> Opportunity<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #003399;">Name</span><span style="color: #339933;">=</span>Silver <span style="color: #003399;">Error</span>, Amount<span style="color: #339933;">=</span><span style="color: #cc66cc;">150000.00</span>, Id<span style="color: #339933;">=</span>00660000009lx17AAA<span style="color: #009900;">&#125;</span>
<span style="color: #cc66cc;">20100210185937.897</span><span style="color: #339933;">:</span>AnonymousBlock<span style="color: #339933;">:</span> line <span style="color: #cc66cc;">2</span>, column <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> Opportunity<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #003399;">Name</span><span style="color: #339933;">=</span>Visual Force, Amount<span style="color: #339933;">=</span><span style="color: #cc66cc;">0.00</span>, Id<span style="color: #339933;">=</span>0066000000AFuB8AAL<span style="color: #009900;">&#125;</span>
<span style="color: #cc66cc;">20100210185937.897</span><span style="color: #339933;">:</span>AnonymousBlock<span style="color: #339933;">:</span> line <span style="color: #cc66cc;">1</span>, column <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span>     <span style="color: #003399;">Number</span> of iterations<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span>
&nbsp;
Cumulative resource usage<span style="color: #339933;">:</span>
&nbsp;
Resource usage <span style="color: #000000; font-weight: bold;">for</span> namespace<span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">default</span><span style="color: #009900;">&#41;</span>
<span style="color: #003399;">Number</span> of SOQL queries<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span> out of <span style="color: #cc66cc;">100</span>
<span style="color: #003399;">Number</span> of query rows<span style="color: #339933;">:</span> <span style="color: #cc66cc;">6</span> out of <span style="color: #cc66cc;">10000</span>
<span style="color: #003399;">Number</span> of SOSL queries<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span> out of <span style="color: #cc66cc;">20</span>
<span style="color: #003399;">Number</span> of DML statements<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span> out of <span style="color: #cc66cc;">100</span>
<span style="color: #003399;">Number</span> of DML rows<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span> out of <span style="color: #cc66cc;">10000</span>
<span style="color: #003399;">Number</span> of script statements<span style="color: #339933;">:</span> <span style="color: #cc66cc;">6</span> out of <span style="color: #cc66cc;">200000</span>
Maximum heap size<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span> out of <span style="color: #cc66cc;">2000000</span>
<span style="color: #003399;">Number</span> of callouts<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span> out of <span style="color: #cc66cc;">10</span>
<span style="color: #003399;">Number</span> of Email Invocations<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span> out of <span style="color: #cc66cc;">10</span>
<span style="color: #003399;">Number</span> of fields describes<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span> out of <span style="color: #cc66cc;">10</span>
<span style="color: #003399;">Number</span> of record type describes<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span> out of <span style="color: #cc66cc;">10</span>
<span style="color: #003399;">Number</span> of child relationships describes<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span> out of <span style="color: #cc66cc;">10</span>
<span style="color: #003399;">Number</span> of picklist describes<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span> out of <span style="color: #cc66cc;">10</span>
<span style="color: #003399;">Number</span> of future calls<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span> out of <span style="color: #cc66cc;">10</span>
<span style="color: #003399;">Number</span> of find similar calls<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span> out of <span style="color: #cc66cc;">10</span>
<span style="color: #003399;">Number</span> of <span style="color: #003399;">System</span>.<span style="color: #006633;">runAs</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> invocations<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span> out of <span style="color: #cc66cc;">20</span>
&nbsp;
Total email recipients queued to be sent <span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span>
Cumulative profiling information<span style="color: #339933;">:</span>
&nbsp;
<span style="color: #cc66cc;">1</span> most expensive SOQL operations<span style="color: #339933;">:</span>
AnonymousBlock<span style="color: #339933;">:</span> line <span style="color: #cc66cc;">1</span>, column <span style="color: #cc66cc;">23</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>select Id, <span style="color: #003399;">Name</span>, Amount from Opportunity<span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span> executed <span style="color: #cc66cc;">1</span> time in <span style="color: #cc66cc;">5</span> ms
&nbsp;
No profiling information <span style="color: #000000; font-weight: bold;">for</span> SOSL operations.
&nbsp;
<span style="color: #006633;">No</span> profiling information <span style="color: #000000; font-weight: bold;">for</span> DML operations.
&nbsp;
<span style="color: #006633;">No</span> profiling information <span style="color: #000000; font-weight: bold;">for</span> method invocations.</pre></div></div>

<p>Why do I like this? It is incredibly easy to identify line and column numbers. When debugging I am usually focused on a specific area. In any browser I can hit CTRL-F, enter &#8220;line 142&#8243;, and be taken straight to the area I am debugging. The output is very clean and concise with no unwanted garbage. It simply has my debug statements. It also provides a nice clean summary of limits and the most expensive methods, SOQL, SOSL, and DML statements. This is great information to know when optimizing code. For me this is perfect. The only issue I had with version 1.1 was that if my code had any DML statements it would output all of the work flow and validation criteria because the filters did not work as mentioned above. </p>
<p>Now lets take a look at version 2.0 released with Spring 10.</p>
<p>Below are the filter settings I used for this:</p>

<a href="http://www.tehnrd.com/wp-content/gallery/random/filters.jpg" title="" class="thickbox" rel="singlepic234" >
	<img class="ngg-singlepic ngg-center" src="http://www.tehnrd.com/wp-content/gallery/cache/234__400x_filters.jpg" alt="filters" title="filters" />
</a>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.381</span><span style="color: #339933;">|</span>EXECUTION_STARTED
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.381</span><span style="color: #339933;">|</span>CODE_UNIT_STARTED<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span>EXTERNAL<span style="color: #009900;">&#93;</span><span style="color: #003399;">System</span> Log <span style="color: #003399;">Window</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.393</span><span style="color: #339933;">|</span>METHOD_ENTRY<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>system.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span>SOBJECT<span style="color: #339933;">:</span>Opportunity<span style="color: #009900;">&#41;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.393</span><span style="color: #339933;">|</span>USER_DEBUG<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>DEBUG<span style="color: #339933;">|</span>Opportunity<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #003399;">Name</span><span style="color: #339933;">=</span>Edge SLA, Amount<span style="color: #339933;">=</span><span style="color: #cc66cc;">60000.00</span>, Id<span style="color: #339933;">=</span>006A0000002YZZ9IAO<span style="color: #009900;">&#125;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.393</span><span style="color: #339933;">|</span>METHOD_EXIT<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>debug<span style="color: #009900;">&#40;</span>ANY<span style="color: #009900;">&#41;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.393</span><span style="color: #339933;">|</span>METHOD_ENTRY<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>system.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span>SOBJECT<span style="color: #339933;">:</span>Opportunity<span style="color: #009900;">&#41;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.393</span><span style="color: #339933;">|</span>USER_DEBUG<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>DEBUG<span style="color: #339933;">|</span>Opportunity<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #003399;">Name</span><span style="color: #339933;">=</span>Grand Hotels Kitchen Generator, Amount<span style="color: #339933;">=</span><span style="color: #cc66cc;">15000.00</span>, Id<span style="color: #339933;">=</span>006A0000002YZZAIA4<span style="color: #009900;">&#125;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.393</span><span style="color: #339933;">|</span>METHOD_EXIT<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>debug<span style="color: #009900;">&#40;</span>ANY<span style="color: #009900;">&#41;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.394</span><span style="color: #339933;">|</span>METHOD_ENTRY<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>system.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span>SOBJECT<span style="color: #339933;">:</span>Opportunity<span style="color: #009900;">&#41;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.394</span><span style="color: #339933;">|</span>USER_DEBUG<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>DEBUG<span style="color: #339933;">|</span>Opportunity<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #003399;">Name</span><span style="color: #339933;">=</span>Grand Hotels SLA, Amount<span style="color: #339933;">=</span><span style="color: #cc66cc;">90000.00</span>, Id<span style="color: #339933;">=</span>006A0000002YZZBIA4<span style="color: #009900;">&#125;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.394</span><span style="color: #339933;">|</span>METHOD_EXIT<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>debug<span style="color: #009900;">&#40;</span>ANY<span style="color: #009900;">&#41;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.394</span><span style="color: #339933;">|</span>METHOD_ENTRY<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>system.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span>SOBJECT<span style="color: #339933;">:</span>Opportunity<span style="color: #009900;">&#41;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.394</span><span style="color: #339933;">|</span>USER_DEBUG<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>DEBUG<span style="color: #339933;">|</span>Opportunity<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #003399;">Name</span><span style="color: #339933;">=</span>Express Logistics Portable Truck Generators, Amount<span style="color: #339933;">=</span><span style="color: #cc66cc;">80000.00</span>, Id<span style="color: #339933;">=</span>006A0000002YZZCIA4<span style="color: #009900;">&#125;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.394</span><span style="color: #339933;">|</span>METHOD_EXIT<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>debug<span style="color: #009900;">&#40;</span>ANY<span style="color: #009900;">&#41;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.394</span><span style="color: #339933;">|</span>METHOD_ENTRY<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>system.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span>SOBJECT<span style="color: #339933;">:</span>Opportunity<span style="color: #009900;">&#41;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.394</span><span style="color: #339933;">|</span>USER_DEBUG<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>DEBUG<span style="color: #339933;">|</span>Opportunity<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #003399;">Name</span><span style="color: #339933;">=</span>Express Logistics SLA, Amount<span style="color: #339933;">=</span><span style="color: #cc66cc;">120000.00</span>, Id<span style="color: #339933;">=</span>006A0000002YZZDIA4<span style="color: #009900;">&#125;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.394</span><span style="color: #339933;">|</span>METHOD_EXIT<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>debug<span style="color: #009900;">&#40;</span>ANY<span style="color: #009900;">&#41;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.394</span><span style="color: #339933;">|</span>METHOD_ENTRY<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>system.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span>SOBJECT<span style="color: #339933;">:</span>Opportunity<span style="color: #009900;">&#41;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.394</span><span style="color: #339933;">|</span>USER_DEBUG<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>DEBUG<span style="color: #339933;">|</span>Opportunity<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #003399;">Name</span><span style="color: #339933;">=</span>Express Logistics Standby Generator, Amount<span style="color: #339933;">=</span><span style="color: #cc66cc;">220000.00</span>, Id<span style="color: #339933;">=</span>006A0000002YZZEIA4<span style="color: #009900;">&#125;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.394</span><span style="color: #339933;">|</span>METHOD_EXIT<span style="color: #339933;">|</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">|</span>debug<span style="color: #009900;">&#40;</span>ANY<span style="color: #009900;">&#41;</span>
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.394</span><span style="color: #339933;">|</span>CODE_UNIT_FINISHED
<span style="color: #cc66cc;">11</span><span style="color: #339933;">:</span>03<span style="color: #339933;">:</span><span style="color: #cc66cc;">30.394</span><span style="color: #339933;">|</span>EXECUTION_FINISHED</pre></div></div>

<p>And this brings us back to the title of this post. If computers could barf I&#8217;m pretty sure it would look like the output above. Basically every pro in the previous example has now become a con. The noisy output makes it difficult to isolate line numbers and specific areas. This small example is not so bad but imagine a debug log with hundreds if not thousands of lines. What was done in 9 output lines now takes 22 lines! </p>
<p>What is the point of this line: &#8220;11:03:30.394|METHOD_EXIT|[2,2]|debug(ANY)&#8221; when the line that is actually a debug statement says &#8220;|DEBUG|&#8221;. I&#8217;d really like to know as it looks pretty pointless. </p>
<p>This line is also unnecessary, &#8220;11:03:30.394|METHOD_ENTRY|[2,2]|system.debug(SOBJECT:Opportunity)&#8221;. Yes, thank you for letting me know I am debugging an Opportunity. I was the one who wrote this debug statement so I know what I am debugging. The next line that says, &#8220;<em><strong>Opportunity</strong></em>:{Name=Express Logistics&#8221; also lets me know I am debugging an Opportunity. I see how this could be helpful for someone looking at new or unfamiliar code but for me it does nothing more than get in the way.</p>
<p>You will also notice the limit and performance metrics are gone. The only way to get these metrics back is to enable Database logging but then the output starts to includes items that I may not want, again making the output even longer. </p>
<p>Not all is bad with version 2.0. The ability to save the debug logs is useful and the logging criteria actually works.</p>
<p>What I want to be able to do is get a very clean and easy to read output that only displays system.debug() statements with limit and performance metrics. Nearly 2.5 years after I started developing Apex I still don&#8217;t have this and it makes me sad.</p>
<p>Salesforce.com usually gets it right but with this particular feature I feel like they keep striking out. It feels like this tool received little to no customer usability testing. The CRM piece of salesforce is always having usability testing done but I have never been approached to give feedback on the developer tools. I would encourage the salesforce.com dev group to reach out and do a little usability testing. It doesn&#8217;t need to be super formal usability testing. Quick online group meetings with force.com developers would suffice. There are plenty of good force.com developers out here that are more than willing to give constructive feedback on features like this.</p>
<p>The issues I have expressed concern about may eventually be fixed but we are at least four months away from the next release and based on past changes (or lack there of) to this tool I can&#8217;t be optimistic that improvements will be made quickly. This tool is was close to being perfect and I think it could have hit a home run if it incorporated some user feedback before it was rolled out. </p>
<p>&lt;/end rant&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tehnrd.com/if-computers-could-barf-salesforce-debug-log/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Add Slider to a Visualforce Page with jQuery</title>
		<link>http://www.tehnrd.com/add-slider-to-a-visualforce-page-with-jquery/</link>
		<comments>http://www.tehnrd.com/add-slider-to-a-visualforce-page-with-jquery/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 18:38:12 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Visualforce]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.tehnrd.com/?p=321</guid>
		<description><![CDATA[A while back Jeff Douglas posted on his blog how to embed a Flex slider into a visualforce page. This is pretty slick and can be really useful, but I&#8217;m not a really a fan of Flex (I&#8217;ll post about that later) so today let&#8217;s look at doing the same thing a little different.
Instead of [...]]]></description>
			<content:encoded><![CDATA[<p>A while back Jeff Douglas posted on his blog <a href="http://blog.jeffdouglas.com/2009/10/29/embed-a-flex-slider-in-a-visualforce-page/" target="_blank">how to embed a Flex slider into a visualforce page</a>. This is pretty slick and can be really useful, but I&#8217;m not a really a fan of Flex (I&#8217;ll post about that later) so today let&#8217;s look at doing the same thing a little different.</p>
<p>Instead of using Flex to build the slider I will show you how to do this with javascript. This requires less code and I feel it is easier to implement. </p>
<p>We are going to add a super nifty ultra slick slider with<em><strong> </strong></em><strong>only 16</strong> lines of javascript code.</p>
<p>You can check out the <strong><a href="http://tehnrddemos-developer-edition.na7.force.com/slider?id=a03A00000016qUL"> working demo by clicking here.</a></strong>.</p>
<p>Below is all of the Visualforce markup, jQuery script, and Apex code. I&#8217;ve added most of my notes on what everything does in the comments but feel free to let me know if something isn&#8217;t clear or if you have any questions.</p>
<p>The one piece that may jump out at you is why I am using the native javascript getElementbyId method when assigning values to the inputFields. It is because these fields are apex:inputFields and they are given a funky Id that looks like this:</p>
<p>page:form:block:values:budgetHigh</p>
<p>The auto generation of these ids is cool as it prevents duplicate Ids but the semi-colons in the Id wreak havoc on jQuery. Using regular javascript wasn&#8217;t that much more work and there were no issues.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:page</span> <span style="color: #000066;">standardController</span>=<span style="color: #ff0000;">&quot;Demo__c&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;page&quot;</span> <span style="color: #000066;">extensions</span>=<span style="color: #ff0000;">&quot;slider&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- Here we incldued the necessary jquery javascript and css files --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:includeScript</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!URLFOR($Resource.jquery, 'js/jquery-1.3.2.min.js')}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:includeScript</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!URLFOR($Resource.jquery, 'js/jquery-ui-1.7.2.custom.min.js')}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:stylesheet</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!URLFOR($Resource.jquery, 'css/ui-lightness/jquery-ui-1.7.2.custom.css')}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>    
        //This will load as soon as the page is ready and will setup our slider
        $(document).ready(function(){
            $(&quot;#slider-range&quot;).slider({ //This line creates a slider on the DIV specified, options are passed arguments, comma separated below
                range: true, //This give the slider and top and bottom
                min: 0, //Min value for slider
                max: 1000, //Max value for slider
                values: ['{!FlOOR(Demo__c.Budget_Low__c)}', '{!FLOOR(Demo__c.Budget_High__c)}'], //Start values for the slider
                slide: function(event, ui){ //This function executes every time slider is moved and applies the slider values to the input fields as well as the output below the slider
                    document.getElementById('{!$Component.page.form.block.values.budgetLow}').value = ui.values[0];
                    document.getElementById('{!$Component.page.form.block.values.budgetHigh}').value = ui.values[1];
                    $(&quot;#amountValue&quot;).html('$' + ui.values[0] + 'K - $' + ui.values[1] + 'K');
                }
            });
&nbsp;
            //This line executes only once right after the page is loaded and after the slider is initialized. It creates the &quot;$273K - $611K&quot; text on load
            $(&quot;#amountValue&quot;).html('$' + $(&quot;#slider-range&quot;).slider(&quot;values&quot;, 0) + 'K - $' + $(&quot;#slider-range&quot;).slider(&quot;values&quot;, 1) + 'K');
        });
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:form</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;form&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:pageBlock</span> <span style="color: #000066;">mode</span>=<span style="color: #ff0000;">&quot;edit&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;block&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:pageBlockButtons</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:commandButton</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Save&quot;</span> <span style="color: #000066;">action</span>=<span style="color: #ff0000;">&quot;{!save}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:pageBlockButtons<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:pageBlockSection</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:outputField</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!Demo__c.Name}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:pageBlockSection<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:pageBlockSection</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Budget Info&quot;</span> <span style="color: #000066;">columns</span>=<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:pageBlockSectionItem</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:outputLabel</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Budget Range&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:pageBlockSectionItem</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
                        <span style="color: #808080; font-style: italic;">&lt;!-- This is where our slider will be --&gt;</span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;slider-range&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;font-size: 90%; margin-top: 0.5em;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;amountValue&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;text-align: center;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:pageBlockSectionItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:pageBlockSectionItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:pageBlockSection<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:pageBlockSection</span> <span style="color: #000066;">columns</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;values&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #808080; font-style: italic;">&lt;!-- You could make these fields apex:inputHidden and then use only the slider --&gt;</span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:inputField</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!Demo__c.Budget_Low__c}&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;budgetLow&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>       
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:inputField</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!Demo__c.Budget_High__c}&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;budgetHigh&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:pageBlockSection<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:pageBlock<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:form<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:page<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Very simple extension. Simply to override the save and prevent demo from returning to record.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> slider <span style="color: #009900;">&#123;</span>
&nbsp;
    Demo__c d<span style="color: #339933;">;</span>        
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> slider<span style="color: #009900;">&#40;</span>ApexPages.<span style="color: #006633;">StandardController</span> controller<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>        
        d <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Demo__c<span style="color: #009900;">&#41;</span>controller.<span style="color: #006633;">getRecord</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>             
    <span style="color: #009900;">&#125;</span>        
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> save<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>        
        update d<span style="color: #339933;">;</span>        
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tehnrd.com/add-slider-to-a-visualforce-page-with-jquery/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>How many lines of Apex code do you have?</title>
		<link>http://www.tehnrd.com/how-many-lines-of-apex-code-do-you-have/</link>
		<comments>http://www.tehnrd.com/how-many-lines-of-apex-code-do-you-have/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 22:07:26 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Apex]]></category>

		<guid isPermaLink="false">http://www.tehnrd.com/?p=481</guid>
		<description><![CDATA[I have always been curious how many lines of Apex code I have written. Is it a couple hundred (haha, ya right), several thousand, a gazillion million trillion? There was never really a good way to figure this out unless you pulled down all of the data and inspected it file by file. Lame. 
Enter [...]]]></description>
			<content:encoded><![CDATA[<p>I have always been curious how many lines of Apex code I have written. Is it a couple hundred (haha, ya right), several thousand, a gazillion million trillion? There was never really a good way to figure this out unless you pulled down all of the data and inspected it file by file. Lame. </p>
<p>Enter Spring 10 and the removal of limits on collection size. Dooo da doooooo (trumpet music)!!!!!!! The data to figure out the number of lines has always been available but it has been difficult to process. All apex class and trigger code is stored in two tables that can be accessed by SOQL. The first part is easy, simply query all of the data, and count the lines. Before Spring 10 there was no good way to count the lines. There is no apex method to count the number of string matches, ie: count number of &#8216;\n&#8217; breaks. There is a split method that cuts up a string based on pattern matches. What we can do is populate a list of strings split by \n. This will create one entry in our list for each line. TADA! Before Spring 10 this would not have worked if a class had more than 1000 lines as a list could only hold 1000 elements.</p>
<p>Now I know lines of code is totally subjective. Some weirdos will write code like this, 7 lines:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> doSomething<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>something<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//do awesomeness</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>While the cool kids will do it like this, 5 lines:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> doSomething<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>something<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//do awesomeness</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>However your write code, the weirdo way or the cool kid way, it is just darn fun to see how many lines you have written.</p>
<p>Here is the code that will give you that answer. Simply copy and paste this to your system log and hit execute. Then dig through a giant debug log that is still horrible (rant on that later) for 3 simple debug lines.</p>
<p>13:35:17.470|USER_DEBUG|[14,1]|DEBUG|Apex Class lines: 21388<br />
13:35:17.470|USER_DEBUG|[15,1]|DEBUG|Apex Trigger lines: 1425<br />
13:35:17.470|USER_DEBUG|[16,1]|DEBUG|Apex Total lines: 22813</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">Integer</span> classLines <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #003399;">Integer</span> triggerLines <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>ApexClass a <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>Select Body From ApexClass<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	List<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> lines <span style="color: #339933;">=</span> a.<span style="color: #006633;">Body</span>.<span style="color: #006633;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	classLines <span style="color: #339933;">+=</span> lines.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>ApexTrigger a <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>Select Body From ApexTrigger<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	List<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> lines <span style="color: #339933;">=</span> a.<span style="color: #006633;">Body</span>.<span style="color: #006633;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	triggerLines <span style="color: #339933;">+=</span> lines.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
system.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Apex Class lines: '</span> <span style="color: #339933;">+</span> classLines<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
system.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Apex Trigger lines: '</span> <span style="color: #339933;">+</span> triggerLines<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
system.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Apex Total lines: '</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>classLines<span style="color: #339933;">+</span> triggerLines<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tehnrd.com/how-many-lines-of-apex-code-do-you-have/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting up jQuery with salesforce.com</title>
		<link>http://www.tehnrd.com/setting-up-jquery-with-salesforce-com/</link>
		<comments>http://www.tehnrd.com/setting-up-jquery-with-salesforce-com/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 04:56:35 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Visualforce]]></category>
		<category><![CDATA[force.com Sites]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.tehnrd.com/?p=454</guid>
		<description><![CDATA[My posts have been lacking lately but in the next few weeks I plan on creating some super slick demos that mix jQuery and Force.com into a delicious concoction of wonderfulness. Before I do this I&#8217;d like to go over the basics of setting up jQuery to play nice with Force.com (or salesforce.com, all the [...]]]></description>
			<content:encoded><![CDATA[<p>My posts have been lacking lately but in the next few weeks I plan on creating some super slick demos that mix jQuery and Force.com into a delicious concoction of wonderfulness. Before I do this I&#8217;d like to go over the basics of setting up jQuery to play nice with Force.com (or salesforce.com, all the same).</p>
<p>If all we need is jQuery, the first thing we need to do is download it here here: <strong><a href="http://jquery.com/">http://jquery.com/</a></strong>.</p>
<p>There will be two versions, one is considered production and the other development. These actually contain the same code but the production file removes all unnecessary spaces. </p>

<a href="http://www.tehnrd.com/wp-content/gallery/random/mr-t_bigger.jpg" title="" class="thickbox" rel="singlepic232" >
	<img class="ngg-singlepic ngg-center" src="http://www.tehnrd.com/wp-content/gallery/cache/232__400x_mr-t_bigger.jpg" alt="mr-t_bigger" title="mr-t_bigger" />
</a>

<p>This smaller version allows the script to be downloaded quicker by users viewing the page and will provide a better user experience to those with less bandwidth.</p>
<p>jQuery lets you do a lot of sweet stuff, manipulate the DOM, change styles, basic animations, etc, but to provide an even richer user experience there is jQueryUI. This allows you to do all sorts of visual awesomeness with very little code. </p>
<p>jQueryUI can be downloaded here:<strong><a href=" http://jqueryui.com/download"> http://jqueryui.com/download</a></strong></p>
<p>When downloading jQueryUI you need to select theme (styles) and all the necessary components. For the sake of demoing and developing it makes sense download all of the components. Once again the reason to leave components out would be to decrease download size.</p>

<a href="http://www.tehnrd.com/wp-content/gallery/random/uidown.png" title="" class="thickbox" rel="singlepic231" >
	<img class="ngg-singlepic ngg-center" src="http://www.tehnrd.com/wp-content/gallery/cache/231__400x_uidown.png" alt="uidown" title="uidown" />
</a>

<p>When you download jQueryUI you will be provided a zip with several files. This contains all sorts of demos and documentation but the only folders we care about are /css and /js. One very important thing to note when downloading jQueryUI is that it automatically downloads the regular jQuery (jQuery Core) to the /js folder.</p>
<p>Since we are going to upload these files as a .zip static resource to force.com I don&#8217;t even bother extracting the contents. Simply delete everything but the /js and /css folders. When this is done we should have a zip file called jquery-ui-1.7.2.custom.zip (or whatever the most current version is). Next we head off to Force.com.</p>
<p>In Force.com navigate to Setup>Develop>Static Resources and hit the New button. Make the name jquery and upload the zip file. If this resource is going to be used with force.com sites be sure Cache Control is set to public.</p>

<a href="http://www.tehnrd.com/wp-content/gallery/random/capture.png" title="" class="thickbox" rel="singlepic229" >
	<img class="ngg-singlepic ngg-center" src="http://www.tehnrd.com/wp-content/gallery/cache/229__400x_capture.png" alt="capture" title="capture" />
</a>

<p>Now create a new visualforce page called jQueryTest. At the very top of the page we need to include the correct script and styles that jQuery has provided. We can do this with the following Visualforce tags:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:includeScript</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!URLFOR($Resource.jquery, 'js/jquery-1.3.2.min.js')}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:includeScript</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!URLFOR($Resource.jquery, 'js/jquery-ui-1.7.2.custom.min.js')}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:stylesheet</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!URLFOR($Resource.jquery, 'css/ui-lightness/jquery-ui-1.7.2.custom.css')}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>With jQuery you will see a lot of examples including the $ symbol. This is basically a shortcut when calling jQuery functions. The problem is that force.com also includes a lot of javascript libraries that also may use this $ symbol as a shortcut and this can cause all sorts of problems. There is a simple fix as we can give jQuery it&#8217;s own special name.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">var j$ <span style="color: #339933;">=</span> jQuery.<span style="color: #006633;">noConflict</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now where ever you would normally use $, use j$.</p>
<p>Finally we make sure it is all working correctly with this simple page. When you click on the link you should see a pop up alert. If you don&#8217;t something isn&#8217;t right so check for typos in the includeScript tags.</p>
<p>You can check out my working demo here: <strong><a href="http://tehnrddemos-developer-edition.na7.force.com/jqueryTest">http://tehnrddemos-developer-edition.na7.force.com/jqueryTest</a><br />
</strong></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:page</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:includeScript</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!URLFOR($Resource.jquery, 'js/jquery-1.3.2.min.js')}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:includeScript</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!URLFOR($Resource.jquery, 'js/jquery-ui-1.7.2.custom.min.js')}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:stylesheet</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!URLFOR($Resource.jquery, 'css/ui-lightness/jquery-ui-1.7.2.custom.css')}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
         var j$ = jQuery.noConflict();
&nbsp;
        j$(document).ready(function(){
            j$(&quot;#ninjaLink&quot;).click(function() {
                alert(&quot;NINJA STAR TO FACE!!!!!&quot;);
            });
        });
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>        
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ninjaLink&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>NINJA ATTACK!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:page<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>After this you are set to start making awesome sauce with jQuery and Force.com.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tehnrd.com/setting-up-jquery-with-salesforce-com/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>If Visualforce Blows, This Sucks</title>
		<link>http://www.tehnrd.com/if-visualforce-sucks-this-blows/</link>
		<comments>http://www.tehnrd.com/if-visualforce-sucks-this-blows/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 22:42:45 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Visualforce]]></category>

		<guid isPermaLink="false">http://www.tehnrd.com/?p=405</guid>
		<description><![CDATA[I recently saw a tweet that included nothing but a link and a lot of salesforce.com related tags. 
Visual Force Blows (link was shortened in original tweet so I couldn&#8217;t see title)
What could this be I pondered? A new product announcement? A glowing review of the force.com platform? Upon clicking the link I entered the [...]]]></description>
			<content:encoded><![CDATA[<p>I recently saw a tweet that included nothing but a link and a lot of salesforce.com related tags. </p>
<p><a href="http://iwritecrappycode.wordpress.com/2009/12/07/visual-force-blows/">Visual Force Blows</a> (link was shortened in original tweet so I couldn&#8217;t see title)</p>
<p>What could this be I pondered? A new product announcement? A glowing review of the force.com platform? Upon clicking the link I entered the &#8220;I hate Apex and Visualforce Zone&#8221; (Dun Dun Dunnnnnnnnnnn). Some dude on a blog (man, everyone has a blog now days) is trying to build a dynamic link menu with data pulled from salesforce objects and using visualforce to display. This seems pretty normal right? Let us check out some excerpts first:</p>
<p>On Apex and Visualforce:</p>
<blockquote><p>Sounds great in theory, however in reality it makes you want to stab yourself. A lot.</p></blockquote>
<p><br/></p>
<p>I on the other hand would bathe in it if I could. Oh ya&#8230;.Visualforce and Apex, sooo bubbly clean. Ya, that was weird. Let&#8217;s move on.<br/><br/></p>
<blockquote><p>Problem is, it uses what is called MVC (Model View Controller, or some shit like that) which divides your logic code, from your design code (oh my god, they invented the idea of functions that can be called, how fucking astounding). Seems like a solid plan, cause your design team and your programming team get to work separately and not step all over each others code. Problem is, I am the design team, and the coding team. That means I get to deal with the whole project from the ground up and deal with all the over engineered bs.</p></blockquote>
<p><br/></p>
<p>Whoa whoa whoa! The harshness, it hurts, but wait a second, isn&#8217;t the MVC concept pretty common. Isn&#8217;t this what all of those crazy iPhone apps use? And about a <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller#Implementations_of_MVC_as_web-based_frameworks">gazillion other languages</a>.</p>
<p>Separating the design team and programming team is not really the purpose of this as both must work together to build awesome apps (even if it is the same person). The real advantage is that the styling/layout and logic are separate. This makes it much easier to code, debug, troubleshoot, and rework in the future. Anyone who has used the old s-controls can atest to this fact. Let us continue.</p>
<p>So what is the developer trying to do. He (she?) wants to simply create a navigation menu with links that have sub links. With his (we will assume it&#8217;s a he, sorry ladies) approach is that it stores all of the link relationships in one object. At first this may seem like a more simple and streamlined approach but this will soon spin out of controll as seen by the post in question. </p>
<p>In cold fusion he said he could do this in 6 lines but it doesn&#8217;t look like the example includes the sub links. So how about a Visualforce solution that includes sublinks in 10 lines of Apex and 11 lines of Visualforce (including class name, Visualforce page, and componenet tags)? Oh ya! It also only took me about 30 minutes to build. Double oh ya!</p>
<p>The first thing I would do differently is break this up into two objects. Link and Sub Link. Why more objects? We can then use the out of the box relationships to query all sub links when we query the links. This will actually significantly reduce the amount of required code. Each object has two text fields, URL and Label. The Sub Link object also has a lookup to the Link object. This approach also makes it much easier to maintain from a admin/user perspective. You can see all sub links for a link on one page.</p>

<a href="http://www.tehnrd.com/wp-content/gallery/random/links.jpg" title="" class="thickbox" rel="singlepic228" >
	<img class="ngg-singlepic ngg-center" src="http://www.tehnrd.com/wp-content/gallery/cache/228__320x240_links.jpg" alt="links" title="links" />
</a>

<p>Before we jump in to the code you can check out the snazzy demo here:</p>
<p><a href="http://tehnrddemos-developer-edition.na7.force.com/linkmenu">http://tehnrddemos-developer-edition.na7.force.com/linkmenu</a></p>
<p>First let&#8217;s look at the controller for the custom component we will be using. What we do is query the link object and all sub links related to the &#8220;parent&#8221; link at the same time. Technically I could make this class have even less lines but this example follows best practices so I won&#8217;t.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> linkMenu<span style="color: #009900;">&#123;</span>
    List<span style="color: #339933;">&lt;</span>Link__c<span style="color: #339933;">&gt;</span> links<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>Link__c<span style="color: #339933;">&gt;</span> getLinks<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>links <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            links <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>select Label__c, URL__c, <span style="color: #009900;">&#40;</span>select Label__c, URL__c from Sub_Links__r<span style="color: #009900;">&#41;</span> from Link__c<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> links<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Next up is the component. This loops through all of the parent links and outputs a hyperlink. For each parent it will then loop through the sub links and create a link that is indented slightly for each.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:component</span> <span style="color: #000066;">controller</span>=<span style="color: #ff0000;">&quot;linkMenu&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:repeat</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!links}&quot;</span> <span style="color: #000066;">var</span>=<span style="color: #ff0000;">&quot;l&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:outputLink</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!l.Url__c}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>{!l.Label__c}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:outputLink<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;br</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:repeat</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!l.Sub_Links__r}&quot;</span> <span style="color: #000066;">var</span>=<span style="color: #ff0000;">&quot;sl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>                
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:outputLink</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!sl.Url__c}&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;margin-left:10px;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>{!sl.Label__c}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:outputLink<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;br</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:repeat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:repeat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>And finally the page. This is were it gets sort of complicated. Sorry about that.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:page</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;c:linkMenu</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:page<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>So what have we learned today? I think if the other post is accurate in its statement that Visualforce blows than I am going to assume that this post really really sucks.</p>
<p>Oh, and don&#8217;t worry Apex and Visualforce creators, PMs, and team. I will protect you.</p>
<blockquote><p>Apex and Visual Force (they are the bane of my existence on this planet and I would die a happy man if their creator(s) where beaten with reeds to within an inch of their life).</p></blockquote>
<p>But seriously, what is up with this guy? I&#8217;ll admit some rants are funny but this is going over the top and you should try to keep it a little professional. Bridge burned. This is that last time I will provide any type of assistance to this guy.</p>
<p><strong>EDIT:</strong> Oh darn! Just realized I named this post &#8220;If Visualforce Sucks, This Blows&#8221;. That was backwards. It is fixed now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tehnrd.com/if-visualforce-sucks-this-blows/feed/</wfw:commentRss>
		<slash:comments>55</slash:comments>
		</item>
		<item>
		<title>Seattle Force.com Developer Meeting</title>
		<link>http://www.tehnrd.com/seattle-force-com-developer-meeting/</link>
		<comments>http://www.tehnrd.com/seattle-force-com-developer-meeting/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 22:45:59 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Visualforce]]></category>

		<guid isPermaLink="false">http://www.tehnrd.com/?p=396</guid>
		<description><![CDATA[Tomorrow, January 7th, there will be another Force.com Developer Meeting in Seattle (first Thursday of every month). If you develop on the Force.com platform with Apex, Visualforce, use the API, or want to learn more about these topics please feel free to join us.
Date: Thursday, January 7th.
Time: 8:00 – 10:00 AM PST
Location: West Monroe Partners
1215 [...]]]></description>
			<content:encoded><![CDATA[<p>Tomorrow, January 7th, there will be another Force.com Developer Meeting in Seattle (first Thursday of every month). If you develop on the Force.com platform with Apex, Visualforce, use the API, or want to learn more about these topics please feel free to join us.</p>
<blockquote><p><strong>Date: Thursday, January 7th.</strong></p>
<p><strong>Time: </strong><strong>8:00 – 10:00 AM PST</strong></p>
<p><strong>Location: West Monroe Partners</strong><strong><br />
</strong>1215 4<sup>th</sup> Ave Suite 1010<br />
Seattle, WA 98109</p>
<p>The West Monroe Partners office is located on the 10<sup>th</sup> floor.</p>
<p>Public Parking garages are located in the building, as well as in a 1-2 block radius. The area is also well serviced by public transportation.</p>
<p>The agenda for this meeting will be as follows:</p>
<ul>
<li><strong>Presentation/Demo</strong> – Jason Venable (<a href="http://tehnrd.com/">tehnrd.com</a>)      will be demoing his runner up application he created for the most recent      Force.com Cloud Developer Challenge. The site is GameForce and includes      two games: Blackjack and multiplayer connect four. (<span style="text-decoration: underline;"><a href="http://tehnrd-developer-edition.na7.force.com/gamehome">http://tehnrd-developer-edition.na7.force.com/gamehome</a></span>). It was built with 100% Force.com, no flash or      JavaScript. Jason is a Salesforce.com Admin and Developer at F5 focused      mainly on process automation for the worldwide sales team.</li>
<li><strong>Open forum </strong>–      opportunity to discuss any questions/issues you may have about all things      Salesforce</li>
</ul>
<p>If you are planning on attending this month’s meeting, please send me an email (<a href="mailto:vgrasparil@westmonroepartners.com">vgrasparil@westmonroepartners.com</a>) to RSVP.</p>
<p>If you would like to present an application you have built or share some best practices you have learned with the group, please let me know so we can schedule it into a future meeting.</p>
<p>See you on January 7th!</p></blockquote>
<p>Yup, thats me! I&#8217;ll be showing off the gaming site I built on force.com, <a href="http://www.tehnrd.com/gameforce/">http://www.tehnrd.com/gameforce/</a>. I&#8217;ll show off the basic UI stuff but we will also peel back the covers to see how it works the magic on the back end.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tehnrd.com/seattle-force-com-developer-meeting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Nerd in Victoria&#8217;s Secret</title>
		<link>http://www.tehnrd.com/a-nerd-in-victorias-secret/</link>
		<comments>http://www.tehnrd.com/a-nerd-in-victorias-secret/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 06:52:55 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.tehnrd.com/?p=386</guid>
		<description><![CDATA[Tonight the wife and I did the after Christmas return run. If you did your return shopping last week you are nuts, unless for some completely logistical reason, you were forced to do it then. We were at the biggest and busiest mall in the state of Washington and it was not busy at all, [...]]]></description>
			<content:encoded><![CDATA[<p>Tonight the wife and I did the after Christmas return run. If you did your return shopping last week you are nuts, unless for some completely logistical reason, you were forced to do it then. We were at the biggest and busiest mall in the state of Washington and it was not busy at all, yet most of the after Christmas sales were still going and merchandise stock was still decent.</p>
<p>One of our first stops was Victoria&#8217;s Secret for an exchange. If you have been shopping lately you know that there are two types of Victoria&#8217;s Secret stores. One, the not so man friendly, and two, the not man friendly at all. The latter are the older ones that still have the pink and gold decor splattered over every surface. The other is the newer remodeled stores which are more modern and use a white, black, and grey color scheme in the store. This particular store was the not so man friendly version.</p>
<p>Fortunately I was with my wife so I could play the part of being dragged into this store against my will, which is actually the preferred image I want to pass off to the other patrons. The other, and much worse image, is you alone. This is not good, as every other female in the store looks at you as if you are a pervert or some dumb husband/boyfriend trying to buy some super sexy outfit that your wife/girlfriend doesn&#8217;t even want. Even if in actuality you are simply purchasing a specific item on their Christmas list!</p>
<p>But I digress. Tonight we are looking to do a straight up exchange but the item was not in stock. We then proceeded to the teller to process the return. The teller, who was a lady in her late 30s, asked what was wrong with the item. We responded. She then asked if we looked for the item we wanted and we said yes. At this point she said, &#8220;Let me have the people in the back check the stock room&#8221;, and at this point used her super spy secret service microphone to ask for help in the back&#8230;&#8230;.no response&#8230;&#8230;..30 seconds&#8230;&#8230;.no response. &#8220;I&#8217;ll just go check myself&#8221;, she says and walks off.</p>
<p>When we first approached the counter I notice something a little strange. All of the tellers had the keyboards for the point of sales system up on the counter facing the customer. I assumed this was for the swath of returns they needed to process which requires the address of the customer returning the item. I figured letting the customer input it themselves would be quicker.</p>
<p>As the lady walked off I turned to my wife and said, &#8220;Heh, suckers. I&#8217;m gonna hack there system&#8221;. &#8220;Don&#8217;t&#8221;, she said but my mind was already committed. What to do? It was just me and the keyboard, the room seemed to fade away, the ridiculous fruity smells vanish, there was silence&#8230;&#8230;&#8230;&#8230;&#8230;.BAM!!!!!! CTRL-ALT-DELETE!!!!!!! WHAT NOW SUCKAS!!!!!!! &#8220;Dang it Jason&#8221;, I heard the wife say, but it was too late, it had been done.</p>
<p>I turned to her and said, &#8220;Don&#8217;t worry, they probably aren&#8217;t even running a system that responds to CTRL-ALT-DELETE. It is probably some Linux based program&#8221;. Or is it&#8230;&#8230;.I slowly began to look over the top of the screen and low and behold the Windows login screen was there, not the Task Manager and not the normal point of sales system. I hacked it! Whuahahahaha! Ya, I know what your&#8217;re thinking, but whatever, let&#8217;s just say I did anyway.</p>
<p>As the lady returned she saw the screen and was sincerely surprised. It was clear the store doesn&#8217;t have the employees login with through windows as she had no idea what to do. At this point my wife was saying, &#8220;I told him not to do it, he is like a child, he has to touch everything&#8221;. The teller responded with, &#8220;Mine is too&#8221;, but she clearly didn&#8217;t know what to do and at this point I leaned over the counter, looked at her screen and then said with suave, &#8220;I&#8217;ll fix it&#8221;. Then with my ninja like computer skills, looking at the screen upside down, used the integrated track ball on the keyboard to move the mouse and hit the Cancel button. At this point my wife was super embarrassed and was blushing big time but everyone was laughing, no harm done. The teller then looked at me and asked, &#8220;You are one of the computer guys. Aren&#8217;t you?&#8221;. &#8220;Ya, something like that I responded&#8221;, and we then headed out of the store.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tehnrd.com/a-nerd-in-victorias-secret/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New Years Doesn&#8217;t Matter</title>
		<link>http://www.tehnrd.com/new-years-doesnt-matter/</link>
		<comments>http://www.tehnrd.com/new-years-doesnt-matter/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 21:44:09 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.tehnrd.com/?p=378</guid>
		<description><![CDATA[Watch out, I&#8217;m about to get all philosophical. New Years is pretty dumb. Yup, it&#8217;s dumb. There are many reasons but here are a few.
Time doesn&#8217;t really exist. Okay, maybe it does, but it is very complicated and thousands of bright minds haven&#8217;t really been able to define time in a way that is acceptable [...]]]></description>
			<content:encoded><![CDATA[<p>Watch out, I&#8217;m about to get all philosophical. New Years is pretty dumb. Yup, it&#8217;s dumb. There are many reasons but here are a few.</p>
<p>Time doesn&#8217;t really exist. Okay, maybe it does, but it is very complicated and thousands of bright minds haven&#8217;t really been able to define time in a way that is acceptable across all studies. But we travel around the sun every 365 days (approximately), hello Jason, that is a year, duh. Actually, that is a measure of rotations and distance that when completed gets a label slapped on it called a year. Oh ya, well there are 24 hours in a day, what about that? 24 is completely arbitrary. It could very well be 50, 20, or 100. They same logic follows for minutes and seconds.</p>
<p>And what is up with January 1st? It&#8217;s completely random and most likely had to do with some religious event back in the day when the church controlled the calendar. The new year could very well start on October 1st. January 1st isn&#8217;t even on a solstice or equinox! If it was, the date might make a little more sense. My years started on February 7th (birthday) an actual event&#8230;.but then again what does February 7th even represent?</p>
<p>New years resolutions are also stupid. If you really want to do something do it today, don&#8217;t wait. Really, whats the point of waiting? &#8220;I&#8217;ll wait until the new year to do something&#8221;, blah blah blah, an excuse to be lazy.</p>
<p>So do I hate everything about new years? No, there are some good things. EXPLOSIONS!!!!!!!! Who doesn&#8217;t like fireworks?</p>

<a href="http://www.tehnrd.com/wp-content/gallery/random/seattlefireworks.jpg" title="" class="thickbox" rel="singlepic227" >
	<img class="ngg-singlepic ngg-center" src="http://www.tehnrd.com/wp-content/gallery/cache/227__320x240_seattlefireworks.jpg" alt="seattlefireworks" title="seattlefireworks" />
</a>

<p>So what will I be doing tonight when the clock hits 12:00AM&#8230;&#8230;&#8230;&#8230;&#8230; the same thing I do every year, hanging out with friends and watching a ball drop or something, just like everyone else.</p>
<p>p.s. Don&#8217;t take this post too seriously, I know my logic has many holes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tehnrd.com/new-years-doesnt-matter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Batch Apex Status Bar</title>
		<link>http://www.tehnrd.com/batch-apex-status-bar/</link>
		<comments>http://www.tehnrd.com/batch-apex-status-bar/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 16:25:09 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Visualforce]]></category>

		<guid isPermaLink="false">http://www.tehnrd.com/?p=356</guid>
		<description><![CDATA[Batch Apex is here and it is cool. In some of the demos and webinars salesforce.com has put together you may have seen a status bar that represents how far along a batch job has proceeded. This is useful as you only need but a quick glance to see how your batch jobs are doing. [...]]]></description>
			<content:encoded><![CDATA[<p>Batch Apex is here and it is cool. In some of the demos and webinars salesforce.com has put together you may have seen a status bar that represents how far along a batch job has proceeded. This is useful as you only need but a quick glance to see how your batch jobs are doing. Below is an image of what this would look like.</p>

<a href="http://www.tehnrd.com/wp-content/gallery/random/batchstatus.jpg" title="" class="thickbox" rel="singlepic226" >
	<img class="ngg-singlepic ngg-center" src="http://www.tehnrd.com/wp-content/gallery/cache/226__320x240_batchstatus.jpg" alt="batchstatus" title="batchstatus" />
</a>

<p>All of this magic status bar stuff is pretty simple. You have two divs, an inner and an outer that construct the status bar, the inner being the percent complete. All of the info to construct this status bar is located in a sObject called AsyncApexJob. This stores information about your batch jobs and other asynchronous operations. </p>
<p>The two important fields in this object are JobItemsProcessed and TotalJobItems. When a batch job is executing it may process millions of records but it will break these up into batches of 200, or less if defined&#8230;&#8230;hence the name <em>Batch Apex</em>. So if I have 5,000 records to be processed there would be 25 batches of 200. In the AsyncApexJob object these 25 batches would be the TotalJobItems. As the job runs the number JobItemsProcessed will increase as the batches are completed. </p>
<p>Now that we have these two number calculating the percent complete is an utterly simple division equation.  JobItemsProcessed divided by TotalJobItems times 100 gives us the percent complete. We then pass this value to the width of the inner div and our status bar is complete! To give the status bar the appearance of being animated we add an actionPoller to the page and rerender the table of batch jobs every five seconds which will intern update that status bar with the new values.</p>
<p>As always there is a fun little demo to play with and you can access that here: <strong><a href="http://tehnrddemos-developer-edition.na7.force.com/batchStatus">Click here for nifty cool demo.</a></strong></p>
<p>I&#8217;ve also packaged up this component so you can install it directly to your org. You can <strong><a href="https://login.salesforce.com/?startURL=%2Fpackaging%2FinstallPackage.apexp%3Fp0%3D04tA00000000ceX">download it here</a></strong>.</p>
<p>Here is all the code and markup. First the page that will contain the batchJobs component.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:page</span> <span style="color: #000066;">controller</span>=<span style="color: #ff0000;">&quot;batchStatus&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:form<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:commandButton</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Start Batch Job&quot;</span> <span style="color: #000066;">action</span>=<span style="color: #ff0000;">&quot;{!startBatch}&quot;</span> <span style="color: #000066;">reRender</span>=<span style="color: #ff0000;">&quot;jobs,error&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span> 
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:outputText</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;error&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!error}&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;font-weight: bold; color: red&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;br</span><span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;br</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;c:batchJobs</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;jobs&quot;</span> <span style="color: #000066;">numberOfJobs</span>=<span style="color: #ff0000;">&quot;20&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:form<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:page<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Next we have the Visualforce component:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:component</span> <span style="color: #000066;">controller</span>=<span style="color: #ff0000;">&quot;batchJobs&quot;</span> <span style="color: #000066;">selfClosing</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;numberOfJobs&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Integer&quot;</span> <span style="color: #000066;">assignTo</span>=<span style="color: #ff0000;">&quot;{!numberOfJobs}&quot;</span> <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;The number of batch jobs to display in the table.&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- Here is the css styles that will be used for the progress bars --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        .progressBar{
            background-color: #f8f8f8;
            border:1px solid #DDDDDD;
            height: 19px;
            width: 300px;
            -moz-border-radius: 5px; 
            -webkit-border-radius: 5px;
        }
        .progress{
            background-color: #F7B64B;
            border:1px solid #E78F08;
            height: 100%;
            margin: -1px;
            text-align: center;
            -moz-border-radius: 5px; 
            -webkit-border-radius: 5px;
            line-height: 18px;
        }
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- This action poller will check the status of the batch jobs every 5 seconds --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:actionPoller</span> <span style="color: #000066;">rerender</span>=<span style="color: #ff0000;">&quot;jobs&quot;</span> <span style="color: #000066;">interval</span>=<span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:pageBlock</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Batch Apex Jobs&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:pageBlockTable</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!batchJobs}&quot;</span> <span style="color: #000066;">var</span>=<span style="color: #ff0000;">&quot;b&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;jobs&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:column</span> <span style="color: #000066;">headerValue</span>=<span style="color: #ff0000;">&quot;Apex Class&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!b.job.ApexClass.Name}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:column</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!b.job.CreatedDate}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:column</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!b.job.CreatedById}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:column</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!b.job.Status}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:column</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;320px&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
                <span style="color: #808080; font-style: italic;">&lt;!-- Here with have two divs that construct our progresses bar. An outter which is the entire bar,</span>
<span style="color: #808080; font-style: italic;">                and and inner that represents the percent complete. We simply pass the percentComplete value to</span>
<span style="color: #808080; font-style: italic;">                the inner div width and this will show how far along the job is. Brilliant! --&gt;</span>
&nbsp;
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;progressBar&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;progress&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;width: {!b.percentComplete}%;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                        {!b.percentComplete}%
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:column<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;apex:column</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;{!b.job.CompletedDate}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:pageBlockTable<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:pageBlock<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/apex:component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>And finally the custom controller for the component&#8230;.. where all the magic happens:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> batchJobs<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>BatchJob<span style="color: #339933;">&gt;</span> batchJobs<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Integer</span> numberOfJobs <span style="color: #009900;">&#123;</span>get<span style="color: #339933;">;</span> set<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>BatchJob<span style="color: #339933;">&gt;</span> getBatchJobs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//Create new list of BatchJobs, a wrapper class that includes the job and percent complete.</span>
        batchJobs <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">List</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//If number of jobs was not defined, default to 20</span>
        <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>numberOfJobs<span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> numberofJobs <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            numberofJobs <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//Query the Batch apex jobs</span>
        <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>AsyncApexJob a <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>select TotalJobItems, Status, NumberOfErrors, MethodName, JobType, JobItemsProcessed, Id, CreatedDate, CreatedById, CompletedDate, ApexClassId, ApexClass.<span style="color: #003399;">Name</span> From AsyncApexJob order by CreatedDate desc limit <span style="color: #339933;">:</span>numberOfJobs<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">Double</span> itemsProcessed <span style="color: #339933;">=</span> a.<span style="color: #006633;">JobItemsProcessed</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">Double</span> totalItems <span style="color: #339933;">=</span> a.<span style="color: #006633;">TotalJobItems</span><span style="color: #339933;">;</span>
&nbsp;
            BatchJob j <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BatchJob<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            j.<span style="color: #006633;">job</span> <span style="color: #339933;">=</span> a<span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">//Determine the pecent complete based on the number of batches complete</span>
            <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>totalItems <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">//A little check here as we don't want to divide by 0.</span>
                j.<span style="color: #006633;">percentComplete</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
                j.<span style="color: #006633;">percentComplete</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>itemsProcessed  <span style="color: #339933;">/</span> totalItems<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">100.0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">intValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            batchJobs.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> batchJobs<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//This is the wrapper class the includes the job itself and a value for the percent complete</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">Class</span> BatchJob<span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">public</span> AsyncApexJob job <span style="color: #009900;">&#123;</span>get<span style="color: #339933;">;</span> set<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Integer</span> percentComplete <span style="color: #009900;">&#123;</span>get<span style="color: #339933;">;</span> set<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">/*--------------------TEST METHOD------------------------*/</span>
    <span style="color: #000000; font-weight: bold;">static</span> testMethod <span style="color: #000066; font-weight: bold;">void</span> batchStatusBarTest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        batchJobs controller <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> batchJobs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        controller.<span style="color: #006633;">getBatchJobs</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I initially planned on adding all sorts of cool features to this component such as color coding the status bar based on the status of the job and estimated time to completion. These were axed in 1.0 as it was taking too long and there our some other cool posts I have lined up that I want to get working on. Maybe in the future I&#8217;ll post an updated version of this component with all the flair it deserves. </p>
<p><strong><u>UPDATE:</u></strong></p>
<p>I&#8217;ve been asked a couple times what exactly happens when a user clicks the  <<em>apex:commandButton value=&#8221;Start Batch Job&#8221; action=&#8221;{!startBatch}&#8221; reRender=&#8221;jobs,error&#8221;/> </em> button. This calls a very simple method in the controller that starts a batch job.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> startBatch<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	error <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	batchJob job <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> batchJob<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	List<span style="color: #339933;">&lt;</span>AsyncApexJob<span style="color: #339933;">&gt;</span> openJobs <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>select Id from AsyncApexJob where Status <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Processing'</span> OR Status <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Queued'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>openJobs.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	        ID batchprocessid <span style="color: #339933;">=</span> Database.<span style="color: #006633;">executeBatch</span><span style="color: #009900;">&#40;</span>job<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
		error <span style="color: #339933;">=</span> <span style="color: #0000ff;">'WHOA BUDDY! Only five batch jobs at a time.'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And here is the batch apex job.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">global <span style="color: #000000; font-weight: bold;">class</span> batchJob <span style="color: #000000; font-weight: bold;">implements</span> Database.<span style="color: #006633;">Batchable</span><span style="color: #339933;">&lt;</span>SObject<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    global database.<span style="color: #006633;">querylocator</span> start<span style="color: #009900;">&#40;</span>Database.<span style="color: #006633;">BatchableContext</span> bc<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> Database.<span style="color: #006633;">getQueryLocator</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'select Id, Name from Account where Type = <span style="color: #000099; font-weight: bold;">\'</span>Batch Test<span style="color: #000099; font-weight: bold;">\'</span>'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    global <span style="color: #000066; font-weight: bold;">void</span> execute<span style="color: #009900;">&#40;</span>Database.<span style="color: #006633;">BatchableContext</span> bc, sObject<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> objects<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        List<span style="color: #339933;">&lt;</span>Account<span style="color: #339933;">&gt;</span> accns <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> List<span style="color: #339933;">&lt;</span>Account<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>sObject s <span style="color: #339933;">:</span> objects<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            Account a <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Account<span style="color: #009900;">&#41;</span>s<span style="color: #339933;">;</span>
            a.<span style="color: #006633;">Description</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'batch testing. blah blah blah.  '</span> <span style="color: #339933;">+</span> system.<span style="color: #006633;">now</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
            accns.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        update accns<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    global <span style="color: #000066; font-weight: bold;">void</span> finish<span style="color: #009900;">&#40;</span>Database.<span style="color: #006633;">BatchableContext</span> bc<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
       system.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'all done'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tehnrd.com/batch-apex-status-bar/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 4.897 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-03-11 04:03:59 -->
