<!-- move these styles into a global definition -->

<style>
.hint {
	color: #ccc;
}

.sparkInput {
	font-size: 12px;
	padding: 5px;
	color: #222222;
	width: 500px;
	font-family: "Lucida Grande",verdana,arial,helvetica,sans-serif;
}

.sparkTextarea {
	width: 500px;
	height: 250px;
	font-size: 14px;
	padding: 3px;
	color: #222222;
	font-family: "Lucida Grande",verdana,arial,helvetica,sans-serif;
}

.sparkButton {
	font-size: 12px;
	padding: 5px;
	color: #222222;
	font-family: "Lucida Grande",verdana,arial,helvetica,sans-serif;
}

.required {
	color: red;
}

</style>

<script>
function toggleEndDate()
{
	if(	document.getElementById('endDateRow').style.display == 'none')
		document.getElementById('endDateRow').style.display = 'block';
	else
		document.getElementById('endDateRow').style.display = 'none';
}

function showNewVenue()
{
	document.getElementById('newVenue').style.display = 'block';
	document.getElementById('venueList').style.display = 'none';
	
}

function showNewLocation()
{
	document.getElementById('event_location_dropdown').style.display = 'none';
	document.getElementById('event_location_new').style.display = 'block';
	
}

</script>


<style>
	.sparkInput {
		width: 250px;
	}

</style>

<script>

function showNewLocation()
{
	document.getElementById('venue_location_dropdown').style.display = 'none';
	document.getElementById('venue_location_new').style.display = 'block';
	
}

</script>

<?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>Colin Loretz &#187; Salesforce.com</title>
	<atom:link href="http://colinloretz.com/category/code/salesforce-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://colinloretz.com</link>
	<description>Technology &#38; Life Hacking</description>
	<lastBuildDate>Thu, 17 Jun 2010 22:02:40 +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>Calculating the day of the week in Apex code</title>
		<link>http://colinloretz.com/2010/01/calculating-the-day-of-the-week/</link>
		<comments>http://colinloretz.com/2010/01/calculating-the-day-of-the-week/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 09:41:48 +0000</pubDate>
		<dc:creator>Colin Loretz</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Salesforce.com]]></category>

		<guid isPermaLink="false">http://colinloretz.com/?p=582</guid>
		<description><![CDATA[Formatting dates has always been the bane of my existence and tonight, I couldn&#8217;t figure out how to calculate the day of the week based on a date when coding in apex on the Force.com platform. I found this wikipedia article: Calculating the day of the week and used it to build the following function. [...]]]></description>
			<content:encoded><![CDATA[<p>Formatting dates has always been the bane of my existence and tonight, I couldn&#8217;t figure out how to calculate the <strong>day of the week</strong> based on a date when coding in apex on the Force.com platform. I found this wikipedia article: <a href = "http://en.wikipedia.org/wiki/Calculating_the_day_of_the_week">Calculating the day of the week</a> and used it to build the following function.</p>
<p>This function will determine the day of the week for any date, including leap years. It can be cleaned up considerably but I figured I would share my geekery with you all in raw form. (Y3k bug: note the <em>- 2000</em> to calculate the last two digits of the year.)<br />
<span id="more-582"></span></p>
<pre>public String readableDay(Date dateToFormat)
{
	String dayOfWeekString = '';
	Integer day = dateToFormat.day();
	Integer month = dateToFormat.month();

	//Get last two digits of year
	Integer twoDigitYear = dateToFormat.year() - 2000;

	//Get first two digits of year
	String centuryYear = String.valueOf(deadline.year());
	centuryYear = centuryYear.substring(0,2);
	Integer centuryYearInt = Integer.valueOf(centuryYear);

	//Centuries: c = 2(3 - (century mod 4))
	//century = last two numbers of the year
	Integer modYear = math.mod(centuryYearInt, 4);
	modYear = 3 - modYear;
	Integer century = 2 * modYear;
	System.debug('Century: ' + century);

	//Years: y = year + (year / 4)
	Integer years = twoDigitYear + (twoDigitYear / 4);

	//Months (check if leap year)
	Integer monthResult = 0;

	if(month == 1)
	{
		if(math.mod(deadline.year(), 4) == 0)
			monthResult = 6;	//leap year
		else
			monthResult = 0;	//not leap year
	}
	else if(month == 2)
	{
		if(math.mod(deadline.year(), 4) == 0)
			monthResult = 2;	//leap year
		else
			monthResult = 3;	//not leap year
	}
	else if(month == 3)
		monthResult = 3;
	else if(month == 4)
		monthResult = 6;
	else if(month == 5)
		monthResult = 1;
	else if(month == 6)
		monthResult = 4;
	else if(month == 7)
		monthResult = 6;
	else if(month == 8)
		monthResult = 2;
	else if(month == 9)
		monthResult = 5;
	else if(month == 10)
		monthResult = 0;
	else if(month == 11)
		monthResult = 3;
	else if(month == 12)
		monthResult = 5;

	//Calculate Running Total
	Integer runningTotal = century + years + monthResult + day;

	//Calculate mod of week
	Integer dayOfWeek = math.mod(runningTotal, 7);

	//Day of Week Table
	if(dayOfWeek == 0)
		dayOfWeekString = 'Sunday';
	else if(dayOfWeek == 1)
		dayOfWeekString = 'Monday';
	else if(dayOfWeek == 2)
		dayOfWeekString = 'Tuesday';
	else if(dayOfWeek == 3)
		dayOfWeekString = 'Wednesday';
	else if(dayOfWeek == 4)
		dayOfWeekString = 'Thursday';
	else if(dayOfWeek == 5)
		dayOfWeekString = 'Friday';
	else if(dayOfWeek == 6)
		dayOfWeekString = 'Saturday';

	return dayOfWeekString;

}</pre>
]]></content:encoded>
			<wfw:commentRss>http://colinloretz.com/2010/01/calculating-the-day-of-the-week/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Introducing my Unofficial Basecamp + Salesforce.com Toolkit</title>
		<link>http://colinloretz.com/2009/11/introducing-basecamp-salesforce-com/</link>
		<comments>http://colinloretz.com/2009/11/introducing-basecamp-salesforce-com/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 15:00:04 +0000</pubDate>
		<dc:creator>Colin Loretz</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Salesforce.com]]></category>
		<category><![CDATA[37signals]]></category>
		<category><![CDATA[basecamp]]></category>
		<category><![CDATA[df09]]></category>
		<category><![CDATA[dreamforce]]></category>
		<category><![CDATA[forcedotcom]]></category>

		<guid isPermaLink="false">http://colinloretz.com/?p=501</guid>
		<description><![CDATA[For the Force.com developer hackathon, I developed an integration toolkit between 37Signals&#8216; Basecamp application for project management and Salesforce.com. This little bit of work earned me the top prize in the Dreamforce 2009 Hackathon so a big thanks to Salesforce.com for putting on the event. It has easily become my favorite part of the Dreamforce [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-508 alignnone" title="logo" src="http://colinloretz.com/wp-content/uploads/2009/11/logo.png" alt="logo" width="300" height="55" /></p>
<p>For the Force.com developer hackathon, I developed an integration toolkit between <a href="http://37signals.com" target="_blank" onclick="pageTracker._trackPageview('/outgoing/37signals.com?referer=');">37Signals</a>&#8216; Basecamp application for project management and Salesforce.com. This little bit of work earned me the top prize in the <a href="http://developer.force.com/hackathon" target="_blank" onclick="pageTracker._trackPageview('/outgoing/developer.force.com/hackathon?referer=');">Dreamforce 2009 Hackathon</a> so a big thanks to Salesforce.com for putting on the event. It has easily become my favorite part of the Dreamforce conference.</p>
<p><a href="http://salesforce.com" target="_blank" onclick="pageTracker._trackPageview('/outgoing/salesforce.com?referer=');">Salesforce.com</a>, in its simplest form, allows for the tracking of business leads, contacts, accounts, opportunities and its development platform extends its functionality to include pretty much whatever a developer can come up with. For many organizations, these salesforce opportunities represent products that are being purchased by another company. What if, however, you are a professional services group? Your services are products in a sense, however the native salesforce.com functionality of products is fairly limited for use for professional services.</p>
<p><strong>Enter Basecamp<br />
</strong><a href="http://basecamphq.com" target="_blank" onclick="pageTracker._trackPageview('/outgoing/basecamphq.com?referer=');">Basecamp</a> allows you to manage companies, projects and the various messages, to-do lists, milestones, files and time tracking for each project.</p>
<p><strong>Your Basecamp is in my Salesforce</strong><br />
This Basecamp+Salesforce.com toolkit allows you to tie Salesforce opportunities to Basecamp projects right out of the box. The toolkit includes methods for all of the Basecamp API methods so developers can build their own applications using whichever Salesforce.com objects and business logic they desire using visualforce and apex code.</p>
<p>Due to the time constraints on the Hackathon competition, the toolkit requires a little bit of work on my part before I deem it ready for releasing to the <a href="http://developer.force.com/codeshare" target="_blank" onclick="pageTracker._trackPageview('/outgoing/developer.force.com/codeshare?referer=');">Force.com Code Share</a>.</p>
<p><strong>Features</strong></p>
<ul>
<li>Tie your Salesforce user account to your Basecamp user account</li>
<li>Associate opportunities to existing Basecamp projects</li>
<li>Create new Basecamp projects from within Salesforce</li>
<li>Create, read, edit and delete project messages, to-do lists and milestones</li>
<li>Manage completion of to-do lists</li>
</ul>
<p><strong>Considerations<br />
<span style="font-weight: normal;">Both Basecamp and Salesforce have methods for alerting users regarding upcoming tasks. The initial version of this integration relies on Basecamp&#8217;s notifications, which can be selected from within Salesforce.</span></strong></p>
<p><strong>Roadmap<br />
<span style="font-weight: normal;">Due to the short timeframe provided during the Dreamforce Hackathon there are a few Basecamp functional areas that were not written into the toolkit. I plan to add these items soon but they may not be in the first version released to the code share.</span></strong></p>
<ul>
<li>Time tracking</li>
<li>Writeboards</li>
<li>Files</li>
</ul>
<p><a href="http://colinloretz.com/wp-content/uploads/2009/11/basecamp_sf1.png"><img class="alignnone size-large wp-image-520" title="basecamp_sf" src="http://colinloretz.com/wp-content/uploads/2009/11/basecamp_sf1-1024x528.png" alt="basecamp_sf" width="500" /></a></p>
<p><a href="http://colinloretz.com/wp-content/uploads/2009/11/basecamp_sf2.png"><img class="size-large wp-image-517" title="basecamp_sf2" src="http://colinloretz.com/wp-content/uploads/2009/11/basecamp_sf2-1024x399.png" alt="basecamp_sf2" width="500" /></a></p>
<p><a href="http://colinloretz.com/wp-content/uploads/2009/11/basecamp_sf3.png"><img class="alignnone size-full wp-image-518" title="basecamp_sf3" src="http://colinloretz.com/wp-content/uploads/2009/11/basecamp_sf3.png" alt="basecamp_sf3" width="500" /></a></p>
<p><small><em>Disclaimer: I am not affiliated with either Salesforce.com, Dreamforce, 37Signals or Basecamp.</em></small></p>
]]></content:encoded>
			<wfw:commentRss>http://colinloretz.com/2009/11/introducing-basecamp-salesforce-com/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>
