Come stalk me at Dreamforce 2012

*Updated 9/14*
DreamForce 2012 is only a few weeks away. You can still register or sign up for a free pass that gets you access to only the keynote addresses and campground. Free is nice, but you don't get access to all the sessions and trainings and more importantly … the Red Hot Chili Peppers concert.
As this will be my sixth (or seventh?) DreamForce, I've already started preparing by getting some new Dr. Scholls and loading up on Vitamin C, since I'll be on my feet talking away most of the time I'm there. If you want to come see me in action, sign up for one of the following;

The code consultations have got to be the most valuable and under-utilized session. (NOTE: You'll have to have a valid Dreamforce registration and login to use the session links above.) Essentially, you sign up for a half-hour one-on-one with a Salesforce expert; usually a senior level developer or Technical Architect (like myself) from Strategic Services (ie Salesforce's consulting division). Given what our hourly rate is, that half hour alone could cover your registration. I can't tell you how many people sign up and then cancel last minute. The people who have come with very specific, detailed, thought-out questions have sometimes walked away with fully coded solution. (Safe Harbor!) So, if you've hit the wall on some code or can't figure out some integration issue, sign up for a consultation today. Even you you can't pre-register, try swinging by the Developer Zone information desk and asking about cancellations. Odds are you can find a free chair. Maybe you'll even find me.

See you soon.

 

Addendum Sept 5 2012 6PM EST- Apparently the Red Hot Chili Peppers are not the only attraction as Dreamforce will host a free music festival the entire week! Check out the details here. Check out this cool video from The Limousines who will be playing Tues 18 at 6:15. Be there or … don't. I will, though.

Advertisements

Salesforce Technical Architect Certification; Part 2 – Review Board

Continued from Salesforce Technical Architect Certification; Part 1 Multiple Choice Exam

BruceleeI’ve just finished the second part of the Salesforce Technical Architect Certification, the live Review Board, and I must say it’s a bit draining. Imagine something like the picture on the left with the questions coming fast and hard. SSO for desktop app!? Oauth! *Hewah!* Improve queries in large data volumes!? Indexing! *Kapow!* Cloud based platform for Ruby!? *Herokuuuu!!!!* Fortunately, my session was held at Salesforce HQ in San Francisco and not Han’s Island, so we were limited to verbal sparring only.

If you’t don’t already know the format, here’s the deal. You have to prepare a presentation – a Case Study, if you will – on a project that you’ve done in the past. This has to be sent to the Certification team at least one week prior to your scheduled appearance before the board. (You’ll get an email with all the details.) On the day of the review, upon arrival you’ll get handed a 4-page written hypothetical case that outlines a company and their requirements for a Salesforce solution. You have 75 minutes to read that and put together your solution. You then present that solution to a board of technical architects for up to 30 minutes followed by 30 minutes of questions. If you take less than 30 minutes to present, that time gets added to the questions portion of the hour. Following a 15 minute break, you’ll get another thirty minutes to present your Case Study followed by 45 minutes of Q&A. Same rule applies. If you use less time to present, you get more time on the hot seat. Finally, the whole thing doesn’t end until you pin the host. I’m not entirely sure about that last part, since by that point I was a bit punchy. You may want to add some extra pushups to your preparation regimin just in case.

In preparation for the board, I had two practice runs with hypothetical cases over the phone and one with my client case in front of a live audience. Based on my experience, my prep, and conversations with people who have completed the certification, here are a few bits of advice that you might find helpful.

Try scheduling your multiple choice exam board just a few weeks prior to the review board. I wish I had signed up for the review board that was held in March, only three weeks after I passed the multiple choice exam (see my previous post). Everything was still fresh in my mind, then. Instead, I opted for the May board thinking I didn’t have enough time to prep my project case. With all the time that passed I ended up having to study up on some key areas all over again. In retrospect, I should have done the case study in parallel with studying for the multiple choice exam and then three weeks would have been sufficient time to do some mock runs.

The mock cases I’ve seen have ranged from 3-5 pages in length and have a lot of detail about the company, requirements, desired process flows, security, and more. There is far more detail than I think is reasonable to read and respond to in the time you are given. This is where I had my epiphany – you are not meant to. In fact, expect that a lot of the Q&A portion will be focused on those areas you weren’t able to cover because that is by design. The board members need to have something to ask you about. It would be really awkward if your 30 minutes of presenting was met with 30 minutes of crickets chirping. So, instead of trying to provide a complete highly detailed solution for each requirement, concentrate your efforts on puling out the major requirements and putting a high level solution overview together. You can’t prepare a powerpoint in advance for this (which had been my original plan). They give you a blank powerpoint template that you can use with a few generic tables and diagrams in the appendix. They also handed me a Windows laptop to use, which given my four year mac conversion, presented other challenges. In my first mock run, which was via GoToMeeting, I spent far too much time trying to get my powerpoint slides together and couldn’t get everything down. Don’t make that mistake. It’s much quicker to use the provided paper to mock up your landscape diagram and ERD’s. For the review board case, I put together only ten slides some of which only had a title and most of which had only 3-4 bullets. My strategy was to use the powerpoint to set my agenda and keep me on track. On the blank slides, I knew to talk to my solution while transfering my drawings from paper to the whiteboard. I put a minimum of text on the other slides knowing that I could take as much or as little time as needed to expand on the bullets. There will be a timer counting down and visible to you and the board members. Keeping my total slide count to ten helped me know exactly where I should be by the 10 minute mark, 20 minute mark, etc.

I found the Q&A much easier, but I know that not everyone does. Just remember to take your time. When you get a question, process what you’re being asked and why, mull over a solution in your head, and speak once you’ve got a thought out answer. If you rush ahead to answer you’re just increasing the number of questions you’ll get. During some answers, I went back to the whiteboard and expanded on previous drawings or diagrammed something completely new. Take the time to answer the question as completely as necessary, but be sure not to ramble on. Once I saw heads nod, I wrapped it up.

The case presentation was much easier because it’s prepared and practiced in advance. My powerpoint was about 20 slides long and was structured as follows;

  • Overview slides; a client description and a project description
  • Systems Landscape diagrams; one before and one after
  • Solution Highlights – pulled three discreet solutions from the overall project and gave two slides to each; one with bullets and one with an supporting diagram
  • Project Reflections – this can include technical challenges or project management issues, lessons learned and maybe decisions that would be made differently in retrospect

The project I selected spanned the last year and a half of my life (and continues to do so). So, given that scope, it was important to pull out only a few ‘highlights’ rather than trying to cover everything the project entailed. I didn’t have anything related to testing and change management in my deck and got a lot of questions on that afterwards. So, it may be helpful to include that somewhere in the mix.

The second Q&A is longer by 15 minutes and it feels even longer since you’ve been talking for an hour and a half by this point. (Remember to bring a water bottle.) It was interesting that not all of the questions focused on the technical aspects of the project. A good number, as I said, were focused on testing and change management. Quite a few others were on coordinating the development team and overall project management.

In all, I think the review board part of the certification does a good job in eliciting those qualities required by a Technical Architect. Being able to present to an audience and field questions with confidence definitely separates a developer from an architect. Both can have the technical expertise, but the role of a TA in the project is more than that. Its one thing to be able to envision a solution. It’s quite another to be able to get people to buy into it. Make sure you’re comfortable on both ends of that spectrum as you prepare.

Hopefully, you find this useful. Good luck!

Update June 26, 2012 – Got the official notice that I passed the certification today. Thanks to everyone that helped make that possible.

Query Tasks, Notes, Attachments by Object Type using SOQL

If you've worked with Salesforce for a while, you've probably come across the gotchas of some of the "standard" sObjects like Task, Event, Note, Attachment and some others. What these all have in common is that rather than having a standard lookup to a single object type, their parent can be any object type. For example, the CampaignMember object can be related to either a Lead or a Contact and has two distinct fields for those links; LeadId and ContactId. If you created a lookup or Master Detail on a custom object, you're asked to select a single object type for the link. In contrast, a Task can also be related to either a Lead or a Contact but has only one field to handle both relationships; WhoId.  

Recently, I needed to run a query in apex where I wanted a list of all the notes related to opportunities. Initially, I tried the following;

//the below does NOT work, LIKE cannot be used with Id fields
SELECT Id, ParentId FROM Note WHERE ParentId like '%006' 

This took me a while to figure out until I delved deeper into the API documentation and found the section Understanding Polymorphic Keys and Relationships . (Up until that point I had incorrectly been calling them dynamic id fields. And I'll probably continue doing so because Polymorphic does not exactly roll off the tongue.) In any case, the below is an example of how I was able to correctly restructure my query.

//returns a list of note records where the parent is a specific type, in this case Opportunity
SELECT Id, Parent.Id, Parent.Type FROM Note WHERE Parent.Type='Opportunity'

The Note object uses ParentId as does Attachment. For other types of objects, like Task and Event, you have the fields WhatId and WhoId. WhoId can relate to Leads and Contacts, while the WhatId is any object that supports activities. Those queries would be structured like;

//returns a list of tasks related to Leads
SELECT Id, Who.Id, Who.Type FROM Task WHERE Who.Type='Lead'

//returns a list of events related to Contacts AND Opportunities
SELECT Id, Who.Id, Who.Type FROM Event WHERE Who.Type='Contact' and What.Type='Opportunity'

One important thing to note (and something I think is unclear in the documentation), is that for the parent you are limited to the fields listed on the Name object. You can't try referencing other standard and custom fields that may be on the parent object. For example;

//This will FAIL even though CreatedDate is a standard field on the opportunity object
SELECT Id, Parent.Id, Parent.Type FROM Note WHERE Parent.Type='Opportunity' AND Parent.CreatedDate = Today

//This will work even though Title isn't even a valid field on the opportunity object
SELECT Id, Parent.Id, Parent.Type FROM Note WHERE Parent.Type='Opportunity' AND Parent.Title != 'Test' 

So, if you did need to filter by values specific to the parent object, you'll need to retructure your query to do a sub-query.  

//restructure your query
SELECT Id, Parent.Id, Parent.Type FROM Note WHERE Parent.Type='Opportunity' AND ParentID in (SELECT Id FROM Opportunity where CreatedDate = Today)

Hopefully, this saves you the 2 hours I spent Googling before breaking down and RTFM. Enjoy.

Cloud based Data Loader

Workbench_logo
On my Mac, I've historically used Simon Fell's LexiLoader as an alternative to the officially supported yet windows-only Salesforce Data Loader. Though, today, I was running a deletion of a rather large set of records and it was running oh sooooo sloooooow. Now that's probably more the fault of Time Warner Cable than anyone else. (Maybe streaming Pandora at the same time didn't help.) If only there was some cloud-based alternative.

Workbench 1Then I remembered about Workbench. Admittedly, I have not used Workbench since its very early release and at that point I think the hosted version was not yet GA. I had even forgotten that I still had it bookmarked. Well, I logged in today and  *Facepalm* . Why have I not been using this all along?

Now I don't do data migrations very often, but I am constantly looking for details on schema and testing queries. Usually I use Eclipse, but navigating Workbench is so much faster. With the pull down menu I can hit a key and get down to my object faster. Workbench loads fields faster than Eclipse as well. I can also use command +f . I can copy and paste an id from a test query or click on the record to open it in Salesforce. These little oft-used hotkey features are noticibly lacking in the Eclipse version of the schema explorer.

Ever need to get your session id? Its right there under the Info menu. 

Want a web based version of Ant? Check the Migration menu.

It even has utilites for anonymous execute and reseting user password. Probably my only complaint is that the debugging interface for anonymous execute isn't as nice as the new console, but really that's just me being nitpicky.

Go check it out for yourself.

Loginhttps://workbench.developerforce.com 
Doc http://wiki.developerforce.com/page/Workbench

Apex RoundingMode

One of the things that always sends me searching through my old code is rounding. I can never remember the syntax and the Apex documentation on Decimal methods on the Salesforce Developer site doesn't provide any examples inthe description (Its somewhat hidden up in the Divide method description if you look for it) . So, I thought I'd put a few examples here as a reminder to myself and to share with everyone else Googling it. 

Decimal numberToRound = 12.345;
Decimal roundedUp = numberToRound.round(roundingMode.UP); //result: 13
Decimal roundedDown = numberToRound.round(roundingMode.DOWN); //result: 12
Decimal scaled = numberToRound.setscale(0); //result: 12 – no rounding specified, just removes decimal places
Decimal scaledUp = numberToRound.setscale(0, roundingMode.UP); //result: 13 – no rounding, just removes decimal places

Look at the documentation on the RoundingModes for more detail on Ceiling, Half_Down, Half_Up, etc. 

 

 

Salesforce Technical Architect Certification; Part 1 Multiple Choice Exam

Yesterday, I passed part two of the three-part Technical Architect Certification for Salesforce.com. (Step one being the self-evaluation; which really doesn't count given that its free and you can take it repeatedly until you pass.) The third and final step will be a four hour session presenting two cases in front of a live review board of technical architects. I've got a few months to prepare for that. So, in the meanwhile, I thought I'd do a bit to help anyone who might be prepping for the exam while its still fresh in my mind.

1. Find out what you don't know

When I went through the self evaluation, I wrote down the terms that I was less familiar with and made a point of researching them afterwards. This was helpful because a lot of the study resources listed below will assume a certain level of knowledge and make reference to terms without necessarily defining them for you. Though I've been an architect and working with Salesforce for several years, I didn't come from an EAI background, so I wasn't as familiar with industry jargon like Enterprise Service Bus (ESB) or Execute, Transform, & Load (ETL) as they referred to integration and middleware. Honestly, I only first heard the acronym EAI last week and I had to go look it up. 

So, if you're stronger on the functional side get familiar with Apex and Visualforce to the level where you can define an Apex abstract class and explain how it might differ from an interface. If you are a developer, make sure you know what can be better done with configuration (Declarative) vs code (Programmatic). In the majority of cases, the former will be preferable to the latter. In that same vein, understand when it is better to use synchronous (web service) vs asynchronous (outbound messaging) callouts. If you don't have a background as a network admin, understand proxies and firewalls and how they might need to be configured to successfully allow salesforce to connect to internal systems in the DMZ (also know what that term means).

Personally, I had little direct experience working with SSO, Large Data Volumes (LDV), REST API, and Heroku. So I put a little more focus on those areas.

Learn the differences between three types of SSO available to Salesforce - delegated authentication, SAML, and Oauth – and when using an appexchange partner like Ping Identity might be appropriate. The comparison matrix here was very helpful to that end.

The most important thing about LDV was knowing the line of demarcation; 2 million records or greater. Next understand what it take to import that volume of data. Also, familiarize yourself with skinny tables and know that in some cases you'll need to de-normalize data or create external id fields (which are indexed) for reporting and performance. Lastly, know when to question if importing the data is even the best approach – does it need to be used for reports or processes in Salesforce (ie workflows, escalations, etc) or can be be accessed on demand via web service callouts or mashups. 

Know the difference between Soap, Rest, and Bulk API's and which situations call for each. Also understand the methods for securing inbound API calls and how an external system might verify that an outbound message or callout came from Salesforce – certificates, 2 way SSL, ip restrictions, trusted ips, remote site settings.

2. Dive in

I was fortunate enough to have access to some proprietary webinars and study materials that I can't make publicly available. However, if you are a Salesforce partner look into getting access to the study group in the Partner Academy. Otherwise, if your Salesforce org has paid for Premier Training there are some self-paced technical architect courses available in the online catalog- https://help.salesforce.com/apex/HTTrainingCatalog.

The following is a list of publically-available material that I reviewed prior to the exam. 

http://certification.salesforce.com/Architects

http://wiki.developerforce.com/page/10_Common_Mistakes_Architects_Make

http://wiki.developerforce.com/page/CRC:PlatformArchitecture

http://wiki.developerforce.com/page/CRC:PlatformGovernance

http://wiki.developerforce.com/page/CRC:OrgArchitecture#Force.com_Org_Architectures

http://wiki.developerforce.com/page/CRC:IntegrationArchitecture

http://wiki.developerforce.com/page/Integrating_with_the_Force.com_Platform

http://wiki.developerforce.com/page/CRC:DataArchitecture

http://wiki.developerforce.com/page/CRC:SSO

http://wiki.developerforce.com/page/Single_Sign-On_for_Desktop_and_Mobile_Applications_using_SAML_and_OAuth

http://wiki.developerforce.com/page/Single_Sign-On_with_Force.com_and_Microsoft_Active_Directory_Federation_Services

http://www.salesforce.com/us/developer/docs/ldv/salesforce_large_data_volumes_bp.pdf

http://wiki.developerforce.com/page/DeveloperCoreResources

http://wiki.developerforce.com/page/Architect_Core_Resources

http://bobbuzzard.blogspot.com/2012/02/certified-salesforce-technical.html

3. Exam Tips

The exam itself is 60 questions and 120 minutes long. So, you can't dwell too long on any one question. If I didn't know some of the people who wrote the questions, I would swear some of them were written by lawyers. (I kid because I love.) In all seriousness, there are some questions where you may need to just pass and move on. If you read a question more than two times and find yourself going for a third, just flag it for review, select a random answer, and move to the next. Don't sacrifice five questions you do know for one question that you might. My strategy was to do a first quick pass through the exam and tackle only the easy low hanging fruit. Then I did a second pass on those I had flagged for review (a little less than half) with a better sense of how much time I could afford each. 

The questions follow your typical standardized testing format, in that, of the answers given, one is egregiously incorrect, another is incorrect because of some slight twist in phrasing and of the choices remaining one is better than the other. There were only a handful of questions where the correct answer jumped out at me. In the cases where it didn't, I identified the incorrect answers first and then evaluated those that remained. From what I recall, about the majority of questions were evenly split between selecting a single answer and two. Only a handful required selecting three. You don't get credit for partially correct answers so do give those a bit more time.

 

Good luck.

 

Added May 16, 2012 – Continued in Salesforce Technical Architect Certification; Part 2 – Review Board

Determining Salesforce Server Pod and if Sandbox via Apex

Recently, I’ve developed some apex classes that were doing callouts to external endpoints like CastIron and Worldpay. I was developing those in a sandbox and from that sandbox called to test endpoints. However, when that code was migrated to production, we obviously wanted those to point to the production endpoints. At first, I used Custom Settings to hold the endpoint value, but I had to change that each time I refreshed. I wanted to store both the test and production endpoints in the custom settings and have the code determine which to use based on if it was being called in a Sandbox or not. Unfortunately, there isn’t a IsSandbox() method in Apex. So, I figured out my own.

I started off using the X-Salesforce-Forwarded-To request header listed in the pagereference documentation because it gave me a consistent value for users accessing Salesforce via the standard interface, Partner Portal, and Sites. However, because you’re using ApexPages.currentPage(), this only works if the code is called from a page controller or extension. In my tests, I tried using URL.getSalesforceBaseUrl(), which can be called from regular classes, but it was inconsistent what was received. For example, I tried calling GetHost() and GetAuthority() from the system log and got cs12.salesforce.com. But with with internal and portal users, a visualforce page returned c.cs12.visual.force.com. Conversely, when using sites I received SiteName.SandboxName.cs12.force.com. So, my approach was determine which method to use based on where the call was coming from in order to get consistent results. 

Parsing out the domains gave me the exact pod that I was on (ex NA1 or CS12) and from that I could determine if that pod was a sandbox or not from whether it started with a “c”. (You can see the full list of available Salesforce pods at http://trust.salesforce.com/trust/status/)

Note: I haven’t tested this with a Site with a Custom Web Address or URLRewriter classes. If you do, please add a comment with your results.

Here’s my code;

 


public String currentPod {
String server;
if (ApexPages.currentPage() != null){ //called from VF page
server = ApexPages.currentPage().getHeaders().get('X-Salesforce-Forwarded-To');
} else { //called via standard class
server = URL.getSalesforceBaseUrl().getHost();
}
if ( server != null && server.length() > 0){
server = server.substring(0 ,server.indexOf('.'));
}
return server ;
}
public Boolean isSandbox {
String pod = currentPod();
if (pod != null && pod.length() > 0 && pod.toUpperCase().startsWith('C')){
return true;
}
return false;
}