<?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>The Enforcer.net &#187; Force.com IDE</title>
	<atom:link href="http://theEnforcer.net/category/forcecom-ide/feed/" rel="self" type="application/rss+xml" />
	<link>http://theEnforcer.net</link>
	<description>a force.com blog</description>
	<lastBuildDate>Mon, 31 Oct 2011 22:55:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Making Owner available in Formulas</title>
		<link>http://theEnforcer.net/2010/06/making-owner-available-in-formulas/</link>
		<comments>http://theEnforcer.net/2010/06/making-owner-available-in-formulas/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 07:37:26 +0000</pubDate>
		<dc:creator>The Enforcer</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Data Loader]]></category>
		<category><![CDATA[Force.com IDE]]></category>
		<category><![CDATA[formulas]]></category>

		<guid isPermaLink="false">http://theEnforcer.net/?p=228</guid>
		<description><![CDATA[I was configuring DataLoader to export a list of Opportunities, and I went to select the &#8220;Owner Name&#8221;. However, only OwnerID is available on an Opportunity. &#8220;No problem!&#8221; I think to myself, as I go and create a Custom Field with a formula equal to Owner.Alias. &#8220;What?&#8221; I say in surprise. &#8220;It won&#8217;t let me [...]]]></description>
			<content:encoded><![CDATA[<p>I was configuring DataLoader to export a list of Opportunities, and I went to select the &#8220;Owner Name&#8221;. However, only <code>OwnerID</code> is available on an Opportunity.</p>
<p>&#8220;No problem!&#8221; I think to myself, as I go and create a Custom Field with a formula equal to <code>Owner.Alias</code>.</p>
<p>&#8220;What?&#8221; I say in surprise. &#8220;It won&#8217;t let me access a field on the Owner object!&#8221;</p>
<p><img class="aligncenter size-full wp-image-229" title="NoLink" src="http://theEnforcer.net/wp-content/uploads/2010/06/NoLink.gif" alt="NoLink" width="302" height="136" /></p>
<p>Mmm. This is strange. Then a Google Search reveals an 18-month old Ideas request to <a href="http://sites.force.com/ideaexchange/apex/ideaview?id=08730000000BrqaAAC" target="_blank">Make &#8220;Owner Id&#8221; Look up fields available for formulas</a>.</p>
<p>Oh dear.</p>
<p>Well, that&#8217;s a shame, but it&#8217;s easily solved! I created:</p>
<ul>
<li>A field called <code>Owner_Link__c</code> of type <code>Lookup(User)</code></li>
<li>A Trigger to copy<code> OwnerId</code> to <code>Owner_Link__c</code> when the Owner is changed</li>
<li>A test for the Trigger</li>
</ul>
<p><strong>Trigger:</strong></p>
<pre class="brush: java; title: ; notranslate">
trigger Update_OwnerLink_on_Owner_Update on Opportunity (before update, before insert) {

  // When 'Owner' field is changed, update 'OwnerLink' too

	// Loop through the incoming records
	for (Opportunity o : Trigger.new) {

		// Has Owner chagned?
		if (o.OwnerID != o.Owner_Link__c) {
			o.Owner_Link__c = o.OwnerId;
		}
	}
}
</pre>
<p><strong>Test:</strong></p>
<pre class="brush: java; title: ; notranslate">
public with sharing class TriggerTest_OwnerLink {

	static TestMethod void testOwnerLink() {

		// Grab two Users
		User[] users = [select Id from User limit 2];
		User u1 = users[0];
		User u2 = users[1];

		// Create an Opportunity
		System.debug('Creating Opportunity');
		Opportunity o1 = new Opportunity(CloseDate = Date.newInstance(2008, 01, 01), Name = 'Test Opportunity', StageName = 'New', OwnerId = u1.Id);
		insert o1;

		// Test: Owner_Link should be set to user 1
		Opportunity o2 = [select id, OwnerId, Owner_Link__c from Opportunity where Id = :o1.Id];
		System.assertEquals(u1.Id, o2.OwnerId);
		System.assertEquals(u1.Id, o2.Owner_Link__c);

		// Modify Owner
		o2.OwnerId = u2.Id;
		update o2;

		// Test: Owner_Link should be set to user 2
		Opportunity o3 = [select id, OwnerId, Owner_Link__c from Opportunity where Id = :o2.Id];
		System.assertEquals(u2.Id, o3.OwnerId);
		System.assertEquals(u2.Id, o3.Owner_Link__c);
	}
}
</pre>
<p>This then gave me a new Owner object on my Opportunity on which I could create Formulas:</p>
<p><img src="http://theEnforcer.net/wp-content/uploads/2010/06/Result.png" alt="Result" title="Result" width="626" height="139" class="aligncenter size-full wp-image-234" /></p>
<p>I could also use it in the DataLoader by referring to <code>Owner_Link__r.Alias</code>.</p>
<p>Hooray!</p>
<p>Easy to solve, but it&#8217;s a shame it was necessary.</p>
<h3>The Bottom Line</h3>
<ul class="nomargin">
<li>Formulas can&#8217;t access <code>Opportunity.Owner</code> fields</li>
<li>Create a &#8216;shadow&#8217; field to hold Owner and populate it via a Trigger</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://theEnforcer.net/2010/06/making-owner-available-in-formulas/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Adding multiple fields via metadata</title>
		<link>http://theEnforcer.net/2009/05/adding-multiple-fields-via-metadata/</link>
		<comments>http://theEnforcer.net/2009/05/adding-multiple-fields-via-metadata/#comments</comments>
		<pubDate>Mon, 25 May 2009 01:54:22 +0000</pubDate>
		<dc:creator>The Enforcer</dc:creator>
				<category><![CDATA[Force.com IDE]]></category>
		<category><![CDATA[metadata]]></category>

		<guid isPermaLink="false">http://theEnforcer.net/?p=75</guid>
		<description><![CDATA[Today I had to add 32 Checkbox fields to my Contact object. I could have done this by manually creating each field, but the thought of clicking through over 100 screens didn&#8217;t take my fancy. So, I thought I&#8217;d take the Force.com Metadata API for a spin. The last time I played with Metadata, I [...]]]></description>
			<content:encoded><![CDATA[<p>Today I had to add 32 Checkbox fields to my Contact object. I could have done this by manually creating each field, but the thought of clicking through over 100 screens didn&#8217;t take my fancy. So, I thought I&#8217;d take the Force.com <strong>Metadata API</strong> for a spin.</p>
<p>The <a href="http://theenforcer.net/2008/07/meta-impressed-with-the-new-metadata-migration-tool/" target="_blank">last time</a> I played with Metadata, I did it via the command-line <a href="http://wiki.developerforce.com/index.php/Migration_Tool" target="_blank">Metadata Migration Tool</a> . This time I decided to do it via the IDE.</p>
<p>Fortunately, there&#8217;s plenty of information available on this topic, the best of which are:</p>
<ul>
<li>Eric Santiago&#8217;s <a href="http://www.ericsantiago.com/eric_santiago/2008/06/rapid-salesforce-configuraton-with-eclipse-and-forcecom.html" target="_blank">Video Tutorial: Rapid Salesforce Configuraton with Eclipse and Force.com</a> that even includes a video with step-by-step instructions. Details on adding custom fields starts around 15 minutes into the video.</li>
<li>Jeff Douglas&#8217; blog post on <a href="http://blog.jeffdouglas.com/2008/07/15/migrating-salesforcecom-configurations-with-the-metadata-api-forcecom-migration-tool/" target="_blank">Migrating Salesforce.com Configurations with the Metadata API &amp; Force.com Migration Tool</a></li>
</ul>
<p>First I updated my Force.com IDE extensions in Eclipse (always make sure you&#8217;re working on the most recent version!). One nice feature I see they&#8217;ve added is the ability to select exactly which objects are copied down to the IDE. I simply ticked &#8216;Contacts&#8217; and it appeared in my Package Explorer.</p>
<p><img class="aligncenter" src="http://theenforcer.net/wp-content/uploads/2009/05/select.png" alt="" width="208" height="217" /></p>
<p>Then, I just did a Copy &amp; Paste job on the metadata, changing the labels for each field.</p>
<pre class="brush: jscript; title: ; notranslate">&lt;CustomObject xmlns=&quot;http://soap.sforce.com/2006/04/metadata&quot;&gt;
    &lt;fields&gt;
        &lt;fullName&gt;BI_Owns_Active_Bamboo__c&lt;/fullName&gt;
        &lt;defaultValue&gt;false&lt;/defaultValue&gt;
        &lt;label&gt;Entity Owns Active Bamboo&lt;/label&gt;
        &lt;type&gt;Checkbox&lt;/type&gt;
    &lt;/fields&gt;
    &lt;fields&gt;
        &lt;fullName&gt;BI_Owns_Active_Clover__c&lt;/fullName&gt;
        &lt;defaultValue&gt;false&lt;/defaultValue&gt;
        &lt;label&gt;Entity Owns Active Clover&lt;/label&gt;
        &lt;type&gt;Checkbox&lt;/type&gt;
    &lt;/fields&gt;
etc.</pre>
<p>I then hit Save and the fields magically appeared in Salesforce.com — I was even somewhat naughty and did it straight into my Production instance (although best practice would be to do it in the Sandbox and then copy across / deploy the change).</p>
<p><img class="aligncenter" src="http://theenforcer.net/wp-content/uploads/2009/05/owns.png" alt="" width="439" height="283" /></p>
<p>Okay, I&#8217;ve still got a bit of work to do if I want to add the Checkboxes to my Page Layout, but at least the laborious part is over — the rest is all Drag &amp; Drop!</p>
<h3>The Bottom Line</h3>
<ul class="nomargin">
<li>The latest Force.com IDE facility lets you choose Standard Objects without having to play with <code>package.xml</code></li>
<li>Creating lots of fields can be done quickly via the IDE, rather than the normal Force.com UI</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://theEnforcer.net/2009/05/adding-multiple-fields-via-metadata/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;Deploy to Server&#8221; command has moved in Force.com IDE Summer &#8217;08</title>
		<link>http://theEnforcer.net/2008/07/deploy-to-server/</link>
		<comments>http://theEnforcer.net/2008/07/deploy-to-server/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 12:29:41 +0000</pubDate>
		<dc:creator>The Enforcer</dc:creator>
				<category><![CDATA[Force.com IDE]]></category>

		<guid isPermaLink="false">http://theenforcer.net/?p=13</guid>
		<description><![CDATA[I had a moment of panic today when searching for the Deploy to Server menu option in Eclipse today. Prior to Summer &#8217;08, the Force.com IDE had this command available when right-clicking an code file. Now it only appears if right-clicking the src folder. My thanks to a post on the Salesforce Community forum for [...]]]></description>
			<content:encoded><![CDATA[<p>I had a moment of panic today when searching for the <strong>Deploy to Server</strong> menu option in Eclipse today.</p>
<p>Prior to Summer &#8217;08, the Force.com IDE had this command available when right-clicking an code file. <strong>Now it only appears if right-clicking the <code>src</code> folder.</strong></p>
<p><img class="aligncenter" title="Deploy to Server in src contact menu" src="http://theenforcer.net/wp-content/uploads/2008/07/deploytoserver.png" alt="" width="592" height="232" align="center" /></p>
<p>My thanks to <a href="http://community.salesforce.com/sforce/board/message?board.id=apex&amp;thread.id=5917" target="_blank">a post on the Salesforce Community forum</a> for answering this one!</p>
<p>It reminds me of a time I was visiting a friend with a 4-year old son. The dining chairs had been moved and their son became distressed, saying that the chairs were all wrong. &#8220;Not wrong,&#8221; replied his mother, &#8220;just different.&#8221;</p>
<h3>The Bottom Line</h3>
<ul class="nomargin">
<li>Don&#8217;t panic!</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://theEnforcer.net/2008/07/deploy-to-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

