<?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; s-controls</title>
	<atom:link href="http://theEnforcer.net/category/s-controls/feed/" rel="self" type="application/rss+xml" />
	<link>http://theEnforcer.net</link>
	<description>a force.com blog</description>
	<lastBuildDate>Fri, 30 Jul 2010 07:02:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to avoid the leading zero error when using URLFOR with custom fields</title>
		<link>http://theEnforcer.net/2009/02/how-to-avoid-the-leading-zero-error-when-using-urlfor-with-custom-fields/</link>
		<comments>http://theEnforcer.net/2009/02/how-to-avoid-the-leading-zero-error-when-using-urlfor-with-custom-fields/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 07:07:05 +0000</pubDate>
		<dc:creator>The Enforcer</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[s-controls]]></category>

		<guid isPermaLink="false">http://theenforcer.net/?p=68</guid>
		<description><![CDATA[Once upon a time, I had to Override the standard New button on my Contact object to set a field value as part of the record created. (Specifically, I wanted to set the Account field to a default value.) I did this by creating a Custom S-Control:

It has to be done as an S-Control because [...]]]></description>
			<content:encoded><![CDATA[<p>Once upon a time, I had to Override the standard New button on my Contact object to set a field value as part of the record created. (Specifically, I wanted to set the Account field to a default value.) I did this by creating a Custom S-Control:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://theenforcer.net/wp-content/uploads/2009/02/override_new.png" alt="" width="772" height="333" /></p>
<p style="text-align: left;">It has to be done as an S-Control because the &#8216;Override&#8217; function only permits S-Controls and Visualforce pages:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://theenforcer.net/wp-content/uploads/2009/02/override.png" alt="" width="638" height="265" /></p>
<p>That all went very well.</p>
<h3>Cloning</h3>
<p>I have since been requested by my users to permit Cloning of a Contact record. Here at Atlassian, we have Contacts with two Record Types:</p>
<ul>
<li>Manually created: Fully editable within Salesforce</li>
<li>Imported from our Customer Database: Mostly read-only, loaded via DataLoader</li>
</ul>
<p>I have no problems with peole cloning &#8216;Manually created&#8217; Contact records, so I provide the normal Clone button. However, for Contact records &#8216;Imported from our Customer Database&#8217;, I was not willing to permit cloning because:</p>
<ul>
<li>The record type would need to be changed (to &#8216;Manually created&#8217;)</li>
<li>The ID field from our Customer Database would need to be cleared</li>
<li>Many fields should not actually be cloned (eg Name) because the prime purpose of enabling Clone was to save typing when creating a new Contact from the same company as an existing Contact</li>
</ul>
<p>In the end, instead of a &#8216;Clone&#8217; button, I decided to implement a &#8216;Copy&#8217; button that created a new record but automatically copied selected fields across to the new record:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://theenforcer.net/wp-content/uploads/2009/02/copy.jpg" alt="" width="738" height="267" /></p>
<p>Two important things to note:</p>
<ul>
<li>Field values are passed in the URL, eg &#8216;con4&#8242; is the Account field</li>
<li>I appended a custom field to the end</li>
</ul>
<p>The technique of setting fields in the URL is standard in the user community. I don&#8217;t know if it&#8217;s meant to be officially done, but enough people do it that it is pseudo-official. I get field names (eg con4, con19street) by viewing the Page Source of the Salesforce page and looking for the field of interest. Hopefully they&#8217;ll stay the same across change to the Page Layout.</p>
<p>Custom fields, however, are <a href="http://community.salesforce.com/sforce/board/message?board.id=ajax_toolkit&amp;message.id=7465" target="_blank">known to produce problems</a>. Rather than having a nice field name (eg conRegion__c), the Page Source uses the ID of the custom field. You can prove this by putting the ID in a URL, such as na1.salesforce.com/00N20000001Bx9v. Unfortunately, this results in an error because the URL doesn&#8217;t understand something that starts with two zeros.</p>
<p>By a stroke of luck, I found that I could <strong>append the Custom Field to the end of the URL </strong>(outside the URLFOR command), which would be correctly added to the generated URL that creates the new object. This has driven people crazy for ages, so I figured it was worth a blog post to help future generations of Salesforce Administrators!</p>
<h3>The Bottom Line</h3>
<ul class="nomargin">
<li>Add custom fields to a URL by placing the custom field assignment AFTER the actual URLFOR statement</li>
<li>It can be easier to create a New record rather than a Clone, especially if you don&#8217;t want to copy most fields</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://theEnforcer.net/2009/02/how-to-avoid-the-leading-zero-error-when-using-urlfor-with-custom-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Be careful when inserting variables into S-Controls</title>
		<link>http://theEnforcer.net/2008/05/be-careful-when-inserting-variables-into-s-controls/</link>
		<comments>http://theEnforcer.net/2008/05/be-careful-when-inserting-variables-into-s-controls/#comments</comments>
		<pubDate>Sat, 24 May 2008 12:01:28 +0000</pubDate>
		<dc:creator>The Enforcer</dc:creator>
				<category><![CDATA[s-controls]]></category>

		<guid isPermaLink="false">http://theenforcer.net/?p=3</guid>
		<description><![CDATA[Can you spot the error in this code?
if ( {!Contact.Department} == 'Finance' )
...
Come on &#8212; try and guess it before reading the next paragraph!
The problem is that Salesforce.com inserts the value of the variable within the S-Control text, resulting in this:
if ( Finance == 'Finance' )
It should really go in quotes like this:
if ( '{!Contact.Department}' [...]]]></description>
			<content:encoded><![CDATA[<p>Can you spot the error in this code?</p>
<pre>if ( {!Contact.Department} == 'Finance' )
...</pre>
<p>Come on &#8212; try and guess it before reading the next paragraph!</p>
<p>The problem is that Salesforce.com <strong>inserts the value of the variable</strong> within the S-Control text, resulting in this:</p>
<pre>if ( Finance == 'Finance' )</pre>
<p>It should really go <strong>in quotes</strong> like this:</p>
<pre>if ( <span style="color: red;">'</span>{!Contact.Department}<span style="color: red;">'</span> == 'Finance' )</pre>
<p>That one gets me every time!</p>
<h3>The Bottom Line</h3>
<ul class="nomargin">
<li>Quote inserted field names when they are strings</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://theEnforcer.net/2008/05/be-careful-when-inserting-variables-into-s-controls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m world-famous in the Salesforce wiki</title>
		<link>http://theEnforcer.net/2008/04/wiki/</link>
		<comments>http://theEnforcer.net/2008/04/wiki/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 01:16:50 +0000</pubDate>
		<dc:creator>The Enforcer</dc:creator>
				<category><![CDATA[s-controls]]></category>

		<guid isPermaLink="false">http://theenforcer.net/?p=38</guid>
		<description><![CDATA[I recently created an S-Control that displays contacts related by Email Address.

I was quite proud of my effort and, since I&#8217;m quite familiar with wikis (Atlassian sells a darn good one!), I decided to contribute my code to the developer.salesforce.com wiki. I&#8217;m a big believer in sharing information and I&#8217;ve gained a lot from the [...]]]></description>
			<content:encoded><![CDATA[<p>I recently created an S-Control that displays contacts related by Email Address.</p>
<p style="text-align: center;"><img title="Related Contacts" src="http://theenforcer.net/wp-content/uploads/2008/07/related_contacts.png" alt="" width="332" height="115" /></p>
<p>I was quite proud of my effort and, since I&#8217;m quite familiar with wikis (<a title="Confluence, the Enterprise Wiki" href="http://atlassian.com/confluence" target="_blank">Atlassian sells a darn good one!</a>), I decided to contribute my code to the <strong><a href="http://developer.salesforce.com" target="_blank">developer.salesforce.com</a> wiki</strong>. I&#8217;m a big believer in sharing information and I&#8217;ve gained a lot from the Community information online.</p>
<p>I received a few messages and feedback from people, which gave me the warm-fuzzies and made the effort worthwhile, but I was really impressed when I opened the next Salesforce E-Newletter:</p>
<p style="text-align: center;"><img title="Salesforce Developer News banner" src="http://theenforcer.net/wp-content/uploads/2008/07/developernews.png" alt="" width="645" height="97" /><br />
<img title="S-Controls and AJAX: Showing a pull-down list of related contacts" src="http://theenforcer.net/wp-content/uploads/2008/07/myarticle.png" alt="" width="644" height="149" /></p>
<p>If you want to read the article, you can find it at: <a href="http://wiki.apexdevnet.com/index.php?title=S-Controls_and_AJAX:_Showing_a_pull-down_list_of_related_contacts" target="_blank">S-Controls and AJAX: Showing a pull-down list of related contacts</a>.</p>
<h3>The Bottom Line</h3>
<ul class="nomargin">
<li>Sharing is nice, and it&#8217;s great to be recognised and appreciated. Thank you Salesforce!</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://theEnforcer.net/2008/04/wiki/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
