<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Making Owner available in Formulas</title>
	<atom:link href="http://theEnforcer.net/2010/06/making-owner-available-in-formulas/feed/" rel="self" type="application/rss+xml" />
	<link>http://theEnforcer.net/2010/06/making-owner-available-in-formulas/</link>
	<description>a force.com blog</description>
	<lastBuildDate>Thu, 12 Apr 2012 17:58:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
	<item>
		<title>By: SFDC consultant - Evgeny</title>
		<link>http://theEnforcer.net/2010/06/making-owner-available-in-formulas/comment-page-1/#comment-71464</link>
		<dc:creator>SFDC consultant - Evgeny</dc:creator>
		<pubDate>Thu, 01 Mar 2012 20:48:26 +0000</pubDate>
		<guid isPermaLink="false">http://theEnforcer.net/?p=228#comment-71464</guid>
		<description>Here is a final version which works for custom object

trigger Project_Update_OwnerLink on Project__c (before Insert, before Update) {

    // Loop through the incoming records
    for(Project__c p:trigger.new) {
         //Owner chagned
        if (p.OwnerID != p.Owner_Link__c) {
            // New Owner is User (not a queue) - update the field
            if(((String)p.OwnerId).substring(0,3) == &#039;005&#039; ){
                p.Owner_Link__c = p.OwnerId;
                }
                else{
            // New Owner is Queue - clear out the field
                p.Owner_Link__c = null;
            }
        }
    }
}</description>
		<content:encoded><![CDATA[<p>Here is a final version which works for custom object</p>
<p>trigger Project_Update_OwnerLink on Project__c (before Insert, before Update) {</p>
<p>    // Loop through the incoming records<br />
    for(Project__c p:trigger.new) {<br />
         //Owner chagned<br />
        if (p.OwnerID != p.Owner_Link__c) {<br />
            // New Owner is User (not a queue) &#8211; update the field<br />
            if(((String)p.OwnerId).substring(0,3) == &#8217;005&#8242; ){<br />
                p.Owner_Link__c = p.OwnerId;<br />
                }<br />
                else{<br />
            // New Owner is Queue &#8211; clear out the field<br />
                p.Owner_Link__c = null;<br />
            }<br />
        }<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evgeny</title>
		<link>http://theEnforcer.net/2010/06/making-owner-available-in-formulas/comment-page-1/#comment-71461</link>
		<dc:creator>Evgeny</dc:creator>
		<pubDate>Tue, 28 Feb 2012 19:51:14 +0000</pubDate>
		<guid isPermaLink="false">http://theEnforcer.net/?p=228#comment-71461</guid>
		<description>Also I&#039;d recommend to update the code with check out if Owner is User (not Queue)
Other wise trigger will return error: &quot;data changed by trigger for field Owner_Link: id value of incorrect type&quot;

Here is a code which could be used for this:

        //Owner is User
        if(o.owner.type==&#039;User&#039;) {
            // Has Owner chagned?
            if (o.OwnerID != o.Owner_Link__c) {o.Owner_Link__c = o.OwnerId;}
        }</description>
		<content:encoded><![CDATA[<p>Also I&#8217;d recommend to update the code with check out if Owner is User (not Queue)<br />
Other wise trigger will return error: &#8220;data changed by trigger for field Owner_Link: id value of incorrect type&#8221;</p>
<p>Here is a code which could be used for this:</p>
<p>        //Owner is User<br />
        if(o.owner.type==&#8217;User&#8217;) {<br />
            // Has Owner chagned?<br />
            if (o.OwnerID != o.Owner_Link__c) {o.Owner_Link__c = o.OwnerId;}<br />
        }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Enforcer</title>
		<link>http://theEnforcer.net/2010/06/making-owner-available-in-formulas/comment-page-1/#comment-71403</link>
		<dc:creator>The Enforcer</dc:creator>
		<pubDate>Sat, 29 Oct 2011 06:33:13 +0000</pubDate>
		<guid isPermaLink="false">http://theEnforcer.net/?p=228#comment-71403</guid>
		<description>I&#039;d have to see your code or data to know what&#039;s going wrong.

I&#039;d suggest writing some code via the System Log to test what&#039;s happening, much along the line of the tests. Try and retrieve a record and look at the value of the link.

Boy, it&#039;s been so long since I wrote that blog that I don&#039;t even remember writing it! :)</description>
		<content:encoded><![CDATA[<p>I&#8217;d have to see your code or data to know what&#8217;s going wrong.</p>
<p>I&#8217;d suggest writing some code via the System Log to test what&#8217;s happening, much along the line of the tests. Try and retrieve a record and look at the value of the link.</p>
<p>Boy, it&#8217;s been so long since I wrote that blog that I don&#8217;t even remember writing it! :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gauravp</title>
		<link>http://theEnforcer.net/2010/06/making-owner-available-in-formulas/comment-page-1/#comment-71401</link>
		<dc:creator>Gauravp</dc:creator>
		<pubDate>Wed, 26 Oct 2011 22:48:13 +0000</pubDate>
		<guid isPermaLink="false">http://theEnforcer.net/?p=228#comment-71401</guid>
		<description>I tried your technique and could access and insert Owner name in the formula field. However, no values are being returned when I test it out. Anything I am doing wrong? attached link has the screenshot. http://tinypic.com/r/2qbgcvk/5</description>
		<content:encoded><![CDATA[<p>I tried your technique and could access and insert Owner name in the formula field. However, no values are being returned when I test it out. Anything I am doing wrong? attached link has the screenshot. <a href="http://tinypic.com/r/2qbgcvk/5" rel="nofollow">http://tinypic.com/r/2qbgcvk/5</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niels</title>
		<link>http://theEnforcer.net/2010/06/making-owner-available-in-formulas/comment-page-1/#comment-71278</link>
		<dc:creator>Niels</dc:creator>
		<pubDate>Tue, 18 Jan 2011 18:14:15 +0000</pubDate>
		<guid isPermaLink="false">http://theEnforcer.net/?p=228#comment-71278</guid>
		<description>Hi again John,

since I like your blog and keep finding useful stuff here, I&#039;m happy to share with you a small improvement I did to your code. The test method failed on my org, since it was using an inactive user. Therefore I modified line 6 like this:

User[] users = [select Id from User where Isactive= True limit 2];

Now it works fine. May be you want to publish this.

Thanks again,
Niels</description>
		<content:encoded><![CDATA[<p>Hi again John,</p>
<p>since I like your blog and keep finding useful stuff here, I&#8217;m happy to share with you a small improvement I did to your code. The test method failed on my org, since it was using an inactive user. Therefore I modified line 6 like this:</p>
<p>User[] users = [select Id from User where Isactive= True limit 2];</p>
<p>Now it works fine. May be you want to publish this.</p>
<p>Thanks again,<br />
Niels</p>
]]></content:encoded>
	</item>
</channel>
</rss>

