<?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>Force.com Tips, Examples &#38; Best Practices</title>
	<atom:link href="http://www.forcetips.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.forcetips.com</link>
	<description>Expert community for Apex, VisualForce, API integration, packaging, and more!</description>
	<lastBuildDate>Sun, 06 Jun 2010 21:19:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Trigger to Automatically Submit Record for Approval</title>
		<link>http://www.forcetips.com/2010/06/trigger-to-automatically-submit-record-for-approval/</link>
		<comments>http://www.forcetips.com/2010/06/trigger-to-automatically-submit-record-for-approval/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 21:19:20 +0000</pubDate>
		<dc:creator>Topalovich</dc:creator>
				<category><![CDATA[Apex Code]]></category>
		<category><![CDATA[Workflow and Approvals]]></category>
		<category><![CDATA[Apex]]></category>
		<category><![CDATA[Approval Process]]></category>
		<category><![CDATA[Force.com]]></category>
		<category><![CDATA[Trigger]]></category>

		<guid isPermaLink="false">http://www.forcetips.com/?p=61</guid>
		<description><![CDATA[<p>Use Case:</p>
<p> You want all new records for an object to be submitted to an Approval Process, but you do not want to rely on users to manually click the &#8216;Submit for Approval&#8217; button after creating the record.</p>
<p>Solution:</p>
<p>After creating and testing a new Approval Process (Setup / App Setup / Create / Workflow &#38; Approvals / <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.forcetips.com/2010/06/trigger-to-automatically-submit-record-for-approval/">Trigger to Automatically Submit Record for Approval</a></span>]]></description>
			<content:encoded><![CDATA[<p><strong>Use Case:</strong></p>
<p><strong> </strong>You want all new records for an object to be submitted to an Approval Process, but you do not want to rely on users to manually click the &#8216;Submit for Approval&#8217; button after creating the record.</p>
<p><strong>Solution:</strong></p>
<p>After creating and testing a new Approval Process (Setup / App Setup / Create / Workflow &amp; Approvals / Approval Processes), implement this simple Apex Trigger (the following example is for the Account object). You will also need to create a test method to ensure code coverage if your current production Apex Classes do not provide adequate coverage. Developers may also want to add try / catch statements to ensure that exceptions are caught and handled properly.</p>
<h2>The Apex Trigger code:</h2>
<p><code><br />
trigger accountApprovalSubmit on Account (after insert) {</code></p>
<p><code></p>
<p style="padding-left: 30px;">for (Account a : trigger.new) {</p>
<p style="padding-left: 60px;">Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();<br />
app.setObjectId(a.id);</p>
<p style="padding-left: 60px;">Approval.ProcessResult result = Approval.process(app);</p>
<p style="padding-left: 30px;">}</p>
<p></code></p>
<p><code>}<br />
</code></p>
<p><strong>Tip submitted by:</strong></p>
<p><a title="Michael Topalovich" href="http://www.linkedin.com/in/topalovich" target="_blank">Michael Topalovich</a><br />
<a title="Force.com application design &amp; architecture" href="http://www.deliveredinnovation.com" target="_blank">Delivered Innovation</a></p>
<p><a title="Force.com application architecture and design" href="http://www.deliveredinnovation.com" target="_blank"><img title="Force.com application architecture and design" src="http://www.forcetips.com/wp-content/uploads/2010/06/Delivered_Innovation_234_100.png" alt="" width="234" height="100" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.forcetips.com/2010/06/trigger-to-automatically-submit-record-for-approval/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create VisualForce Tab to Display Static List View for Standard or Custom Object</title>
		<link>http://www.forcetips.com/2010/06/create-visualforce-tab-to-display-static-list-view-for-standard-or-custom-object/</link>
		<comments>http://www.forcetips.com/2010/06/create-visualforce-tab-to-display-static-list-view-for-standard-or-custom-object/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 16:19:53 +0000</pubDate>
		<dc:creator>Topalovich</dc:creator>
				<category><![CDATA[User Interface]]></category>
		<category><![CDATA[VisualForce]]></category>
		<category><![CDATA[Custom Tab]]></category>
		<category><![CDATA[Custom View]]></category>
		<category><![CDATA[Force.com]]></category>
		<category><![CDATA[Salesforce.com]]></category>

		<guid isPermaLink="false">http://www.forcetips.com/?p=45</guid>
		<description><![CDATA[<p>Use Case:</p>
<p> You would like to create a custom tab to display a specific list view for a standard or custom object rather than use the standard tab view that only displays recently viewed records.</p>
<p>Solution:</p>

From the standard or custom object tab, Edit an existing view or &#8216;Create New View.&#8217;
Ensure that you give the view a Name, <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.forcetips.com/2010/06/create-visualforce-tab-to-display-static-list-view-for-standard-or-custom-object/">Create VisualForce Tab to Display Static List View for Standard or Custom Object</a></span>]]></description>
			<content:encoded><![CDATA[<p><strong>Use Case:</strong></p>
<p><strong> </strong>You would like to create a custom tab to display a specific list view for a standard or custom object rather than use the standard tab view that only displays recently viewed records.</p>
<p><strong>Solution:</strong></p>
<ol>
<li>From the standard or custom object tab, Edit an existing view or &#8216;Create New View.&#8217;</li>
<li>Ensure that you give the view a Name, that you specify filter criteria, that you select the fields to display, and that you restrict visibility as necessary.</li>
<li>When the view has been saved and you are returned to the tab, select the view from the dropdown.</li>
<li>Copy the 15-character view ID in the URL and paste it to Notepad, or write it down.</li>
<li>Create a new VisualForce page (Setup / App Setup / Develop / Pages) using the sample code provided below.</li>
<li>Create a new VisualForce tab (Setup / App Setup / Create / Tabs) and select the VisualForce Page created in Step #5, provide a Tab Label, Tab Name, and Tab Style, and then apply the desired profile visibility for the new tab.</li>
<li>Optional &#8211; hide the tab for the standard or custom object if your new tab is a replacement for the default tab.</li>
<li>If you want to change the View that is displayed in the tab at any time, simply navigate back to the standard tab for the object and Edit the view to meet requirements.</li>
</ol>
<h2>The VisualForce Page code:</h2>
<div id="_mcePaste"><em>Note: Replace &#8220;</em><span style="font-family: 'Courier New', Courier, monospace; line-height: 18px; color: #ff0000;"><em>xxxxxxxxxxxxxxx</em></span><em>&#8221; with the 15-character ID of the View that you captured in Step #4 above.  You can adjust the &#8216;height&#8217;, &#8216;customizable&#8217;, and &#8216;rowsPerPage&#8217; values as desired.</em></div>
<p><code> </code></p>
<p><code></p>
<div>&lt;apex:page &gt;</div>
<div id="_mcePaste" style="padding-left: 30px;">&lt;apex:enhancedList listId="<span style="font-family: 'Courier New', Courier, monospace; line-height: 18px; color: #ff0000;">xxxxxxxxxxxxxxx</span>" height="600" customizable="false" rowsPerPage="25"/&gt;</div>
<div id="_mcePaste">&lt;/apex:page&gt;</div>
<p></code></p>
<p><strong>Tip submitted by:</strong></p>
<p><a title="Michael Topalovich" href="http://www.linkedin.com/in/topalovich" target="_blank">Michael Topalovich</a><br />
<a title="Force.com application design &amp; architecture" href="http://www.deliveredinnovation.com" target="_blank">Delivered Innovation</a></p>
<p><a title="Force.com application architecture and design" href="http://www.deliveredinnovation.com" target="_blank"><img title="Force.com application architecture and design" src="http://www.forcetips.com/wp-content/uploads/2010/06/Delivered_Innovation_234_100.png" alt="" width="234" height="100" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.forcetips.com/2010/06/create-visualforce-tab-to-display-static-list-view-for-standard-or-custom-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Record Type Redirect to VisualForce Page Using Button Override</title>
		<link>http://www.forcetips.com/2010/05/record-type-redirect-to-visualforce-page-using-button-override/</link>
		<comments>http://www.forcetips.com/2010/05/record-type-redirect-to-visualforce-page-using-button-override/#comments</comments>
		<pubDate>Mon, 24 May 2010 21:01:35 +0000</pubDate>
		<dc:creator>Topalovich</dc:creator>
				<category><![CDATA[Apex Code]]></category>
		<category><![CDATA[Custom Buttons]]></category>
		<category><![CDATA[Page Layouts]]></category>
		<category><![CDATA[VisualForce]]></category>
		<category><![CDATA[Apex]]></category>
		<category><![CDATA[Page Layout]]></category>
		<category><![CDATA[Record Type]]></category>
		<category><![CDATA[Standard Controller]]></category>

		<guid isPermaLink="false">http://www.forcetips.com/?p=24</guid>
		<description><![CDATA[<p>This tip originally appeared on SaaSkatoon, the SaaS and cloud computing blog from Delivered Innovation.</p>
<p>Use Case: Client has multiple call centers supporting various product lines; support team ‘A’ requires a custom Wizard to rapidly search for and collect details for the Case record that the standard Salesforce search interface cannot provide.</p>
<p>Solution: While you can assign a <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.forcetips.com/2010/05/record-type-redirect-to-visualforce-page-using-button-override/">Record Type Redirect to VisualForce Page Using Button Override</a></span>]]></description>
			<content:encoded><![CDATA[<p><em>This tip originally appeared on </em><a title="SaaS, PaaS, cloud computing blog" href="http://saaskatoon.deliveredinnovation.com/2009/08/09/force-com-tip-new-button-override-to-assign-visualforce-page-to-specific-record-type-using-native-apex-code/" target="_blank"><em>SaaSkatoon</em></a><em>, the SaaS and cloud computing blog from </em><a title="Force.com application architecture design" href="http://www.deliveredinnovation.com" target="_blank"><em>Delivered Innovation</em></a><em>.</em></p>
<p><strong>Use Case:</strong> Client has multiple call centers supporting various product lines; support team ‘A’ requires a custom Wizard to rapidly search for and collect details for the Case record that the standard Salesforce search interface cannot provide.</p>
<p><strong>Solution:</strong> While you can assign a specific Page Layout to a specific Record Type and embed VisualForce pages in the object Detail view, currently salesforce.com does not support embedded VisualForce Pages in the Edit view of a Page Layout; likewise, salesforce.com does not support custom VisualForce pages for specific Record Types.  The solution is to “intercept” the command to create a new record in an Object before Salesforce processes it, and this is accomplished with a 1-line VisualForce page and a StandardController extension that pulls and analyzes certain URL parameters to enhance the out-of-the-box process routing capabilities of Salesforce.</p>
<p><span id="more-24"></span></p>
<h2>The VisualForce Page code:</h2>
<p><code>&lt;apex:page standardController="Case" extensions="caseRedirect" tabStyle="Case" showheader="true" action="{!redirect}" /&gt;</code></p>
<h2>The Apex controller extension:</h2>
<p><code>public with sharing class caseRedirect {</code></p>
<p><code>private ApexPages.StandardController controller;<br />
public String retURL {get; set;}<br />
public String saveNewURL {get; set;}<br />
public String rType {get; set;}<br />
public String cancelURL {get; set;}<br />
public String ent {get; set;}<br />
public String confirmationToken {get; set;}<br />
public String accountID {get; set;}<br />
public String contactID {get; set;}</code></p>
<p><code>public caseRedirect(ApexPages.StandardController controller) {</code></p>
<p><code> </code></p>
<p><code></p>
<p style="padding-left: 30px;">this.controller = controller;</p>
<p style="padding-left: 30px;">retURL = ApexPages.currentPage().getParameters().get('retURL');<br />
rType = ApexPages.currentPage().getParameters().get('RecordType');<br />
cancelURL = ApexPages.currentPage().getParameters().get('cancelURL');<br />
ent = ApexPages.currentPage().getParameters().get('ent');<br />
confirmationToken = ApexPages.currentPage().getParameters().get('_CONFIRMATIONTOKEN');<br />
saveNewURL = ApexPages.currentPage().getParameters().get('save_new_url');<br />
accountID = ApexPages.currentPage().getParameters().get('def_account_id');<br />
contactID = ApexPages.currentPage().getParameters().get('def_contact_id');</p>
<p>}</p>
<p>public PageReference redirect(){</p>
<p style="padding-left: 30px;">PageReference returnURL;</p>
<p style="padding-left: 30px;">// Redirect if Record Type corresponds to custom VisualForce page</p>
<p style="padding-left: 30px;">IF(rType == '<span style="color: #ff0000;">xxxxxxxxxxxxxxx</span>') {</p>
<p style="padding-left: 60px;">returnURL = new PageReference('/apex/<span style="color: #ff0000;">insert_VF_Page_Here</span>');</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">ELSE {</p>
<p style="padding-left: 60px;">returnURL = new PageReference('/500/e');</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">returnURL.getParameters().put('retURL', retURL);<br />
returnURL.getParameters().put('RecordType', rType);<br />
returnURL.getParameters().put('cancelURL', cancelURL);<br />
returnURL.getParameters().put('ent', ent);<br />
returnURL.getParameters().put('_CONFIRMATIONTOKEN', confirmationToken);<br />
returnURL.getParameters().put('save_new_url', saveNewURL);<br />
returnURL.getParameters().put('nooverride', '1');</p>
<p style="padding-left: 30px;">IF (accountID != null){</p>
<p style="padding-left: 60px;">returnURL.getParameters().put('def_account_id', accountID);</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">IF (contactID != null){</p>
<p style="padding-left: 60px;">returnURL.getParameters().put('def_contact_id', contactID);</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">returnURL.setRedirect(true);</p>
<p style="padding-left: 30px;">return returnURL;</p>
<p>}</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.forcetips.com/2010/05/record-type-redirect-to-visualforce-page-using-button-override/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
