Changing the way Salesforce Admins and Developers think about client solutions.

Restaurants Part 2, Spring ’15, and some Custom Code

You know what I hate about restaurant aggregator sites?  This:Restaurants

Seriously.  Out of all those places, probably 5-10 are a place I would take my wife.  This is really the best they can do?

In my original Restaurants post I talked about how I was excited that come the Spring ’15 release (Safe Harbour!), Google Maps would be native on the Account page.  So now you can get a quick snapshot of where something is without custom code.  I started loading up my restaurants in preparation for the new release.

There are a lot of great things about Spring ’15 and other people have talked about them a lot.

Salesforceweek.ly has a great summary

Arkus has a thorough review

ButtonClickAdmin has lots of information

There is no point in me trying to write my own post so I’m picking a piece and seeing what I can do with it, and that piece is visualforce maps.

Some key things to note here:

  1. I like clicks over code a lot, but what I am trying to do here is show you how the platform can be extended through a bit of code, even by a non-developer like me.
  2. I’m not a developer, so I took this code from elsewhere
  3. I’m not a developer, so I had to piece other pieces together
  4. I’m not a developer, so I’m sure it could be optimized, but it’s working just fine
  5. If I was providing this to a client I would have a developer look over it first, or at least post it to developer.salesforce.com to get a few eyes on it
  6. Everything I learned about coding I learned on SFDC99

Some more things to note here:

  1. Don’t let a little bit of code scare you off.  Find some time to work through something that makes sense to you.
  2. Start small.  Note that I started with what I knew would work, and then slowly built out.  Don’t write 1000 lines of code and then click “save” to see if it works.  That’s just dumb
  3. What better place that to try and work through code is in your own personal dev org?
  4. If you are totally new, head over to SFDC99 and read through it, try a few exercises.  Doing what I did below, which is basically taking code from elsewhere and tweaking it, becomes much easier when you can at least read the code.  Still don’t believe it can be done?  Go read my success story on David’s website.

What I want to do:

Create a custom VisualForce tab that shows all Restaurant accounts in my org.  As I think I said in my first post, my goal is not to have every restaurant in here, just the ones I like or want to go to.  If I could do this natively and for free I would.  I looked at MapPlotter but even then it was managed and limited.  Once I saw this for Spring ’15 I figured why not.

How I did it:

First off, I had to do this in my Spring ’15 preview org so I don’t have all my restaurants in there, I just grabbed a few

Then I “borrowed” the code right from the release notes to get started at the Account level which is set to map all contacts for an account.  It’s ok, this is for the standard Acme account that comes with any dev org


Still not what I’m looking for though.

*It only shows one data point because they all have the same address.  You know you were puzzled by that


I adapted the code to bring back all Accounts and on a custom Visualforce tab like this:

All Accounts

by using this code:

So basically I managed to take the code in the release notes and just bring it out to the Account level using recordSetVal and adjusting some of the notation.  Mainly a trial and error exercise.

There are lots of great places to read about what I just did here with apex:pageBlock and apex:pageBlockSection, but for the most part you’ll find the documentation on developer.salesforce.com in the workbooks.  Also, the power of Google 

So what about those Restaurants?

This is the part that piqued my interest and made me think that I could probably pull it off.

Thanks to the wonders of the community I was able to piece together a few developer.salesforce.com forum entries to realize that I needed a controller extension so I set out to build one.  Basically I only wanted to bring back Accounts with a record type of Restaurant

I give full credit to “sivaext” for giving me enough to go off of here in this post:


So basically I was really close, but I needed an extension to get a subset of records.

 My Extension based on his post:

Not rocket science, just pulling a subset of Accounts based on the record type using a SOQL query.

My new VisualForce Page using the Extension as a filter:

 My Custom Tab:

Setup > Create > Tabs > VisualForce Tab, and then just name your tab.  Not hard at all.  I’m sure there is a reason why the Accounts tab is highlighted instead of the AccountsMap tab but I’m not going to try and figure it out.  Feel free to let me know in the comments!


So I now have a map of restaurants in my area, centred on my house.  It wasn’t that bad and I did it in about an hour.  45 minutes of that was searching google combined with trial and error, but at the end I got the result I was looking for.  The point here is not that it took me too long, it’s recognizing that if you spend enough time at least having the basics down you can know when and where to extend to system to provide a better user experience.  Think about how much time you wasted in school learning stuff you’ll never use again.  Think about how that compares to spending an hour here doing something that I’m quite frankly uncomfortable with, but figure I can piece together.  Do this enough times and you’ll start to have a better understanding of what can be done.

I thought that this would be really useful for subsets of data, and I’ll be using it again in my next set of blog posts on Wine and Wineries.

Words of Wisdom:

Having your own Developer Org is a great way to try stuff like this, even as an Admin.  No pressure from your boss to finish in a certain time, it doesn’t even have to work for months, and you can refine it over time.  Plus if you ever leave the company you work for you don’t lose all the code you made in their Salesforce instance because hopefully you either made it here first, or at least saved a copy here for future reference

Your Salesforce instance ideally should be driven by declarative clicks and not Apex combined with Visualforce but as Iceman said to Maverick at the end of Top Gun:

Code “can be my wingman anytime.”


Share Button


  1. This would be great for appointment booking as well, so you can see account locations in relation to one another. Nice work.

    Btw the “Accounts” tab is highlighted because that’s the default when using standardController=”Account”. I think you can add tabStyle=”AccountsMap__tab” (depending on the API name for your tab) to the apex:page tag to change the highlighted tab.

    • geoffreyflynn

      February 2, 2015 at 8:13 pm

      Thanks Andrew! That was the idea, see if it works and then hopefully other people can use it for something that they find useful.
      For your use case, something like Accounts with an Activity Today would make an interesting use case for sure

1 Pingback

  1. Wine App -

Leave a Reply

Your email address will not be published.


15 + 11 =

© 2018 ExploitedDevOrgs

Theme by Anders NorenUp ↑