Decoding Salesforce

Decoding Salesforce

The hows and whys of Salesforce.com

sfdc-web2anything

Long time no update. I know, I know..

We’ve launched an opensource project to help you generate web forms for the live collection/insertion of data in any standard or custom Salesforce.com object.

sfdc-web2anything

Although Salesforce.com Sites will soon be in Developer Preview, we thought that some Salesforce.com customers could find it useful.

Check the project website for details at Google Code: http://code.google.com/p/sfdc-web2anything/

Apex Code: What you need to get started…

Following on from my previous post.

Below is what you’ll need to get started developing with Apex.

  1. A salesforce.com Developer Edition Account: sign up from the developer site developer.force.com
  2. Apex Documents: available from the Developer Wiki, Apex and Visualforce Section.
  3. The Force.com IDE: just follow the steps on the site to set it up.
  4. A basic understanding of Object Oriented Programming. Personally I’ve done some C and Visual Basic programming in college but not much since. Its a benefit to understand collections and Loop structures, but not essential. If you don’t have a programming background don’t be too worried.
  5. Willingness to Learn and some Spare time: I put this in here for one simple reason, it takes time to learn this stuff and get to grips with it. Personally I’ve been playing around with Apex for a few months now, which has left me no time for this blog.

Next Section: Setting up your first Apex Project…

Tabbed Account page using Visualforce

Ok, so, I’ve been poking around at Visualforce a little in my spare time and I came across this tutorial on how to create a tabbed Account page on the Salesforce Developer site.

Check it out! Tabbed browsing within records in salesforce, this should help tidy up some of those annoyingly long Page Layouts.

I’ve implemented this in my Developer Org and it Looks great, I can’t wait until Visualforce is released to Production.

The World Of Apex

Hi Everyone! Sorry for the long absence from posting.

Where have I been I hear you ask, as the title of the post suggests, I’ve been lost in the “The World of Apex”, as I like to call it.

What is Apex? Apex is salesforce.com’s on demand programming language, it’s similar to Java in its syntax but differs in some important ways; you can get all the info on the force.com developer site.

For an administrator like me Apex is one of the most useful technologies that Salesforce have produced, it allows so much more flexibility when building customization onto your existing applications and building new custom applications.

Before I go into much more detail I want to get one thing clear, I am by no means a developer, I’ve done some small amounts of programming here and there, but nothing substantial, I don’t even hold a college degree, so if I can program Apex so can you!

When I started looking into Apex I was amazed at how powerful it was but found out very quickly how much hassle it can also cause. Salesforce have built what they call governor limits into Apex, which is basically a set of in built limits which you need to work within when developing; you can find more information about it here. The reason for this is that instead of running on your machine, Apex runs completely on the salesforce.com servers and they simply can’t afford that someone would write a program that could hog all the resources on their servers and cause the whole system to crumble.

Over the next few posts (I say posts because I really don’t know how often I’m going to get posting) I’m going to go through some basic concepts of Apex and provide examples of Apex triggers and classes I’ve written.

If you’ve visited the link above to the developer site you’ll also have seen information on that page regarding Visualforce. Visualforce is a HTML like markup language that allows you to restructure and build custom pages and User Interfaces for your salesforce.com implementation, currently its still in a developer preview and isn’t available to your live systems so I won’t be delving into that one just yet.

Well that’s the introductions out of the way, next post: “Getting Started”..

Inline Google Maps

Many have asked me how to integrate Google Maps in a Salesforce.com page to pinpoint a specific address on the map. The example we’re going to see today is how to add an inline map to pinpoint an Account billing address.

The finished product

Here’s a screenshot of what we are going to get:
Inline Google Maps

Let’s get started

Right so, let’s see what we need:

  1. First off you need a Google Map API Key you can obtain for free from here; it’s necessary to embed Google Maps in your own web pages. When requested to insert your website URL, enter the name of the instance you’re on, complete with https:// (e.g.: https://emea.salesforce.com/ )
  2. Then, within Salesforce.com, navigate to Setup > Customize > Develop > S-Controls > New S-Control; specify a Label (e.g.: “Inline GMaps”), set the Type to be HTML, in the HTML Body section paste the following code (don’t forget to substitute YOUR-GOOGLE-MAPS-API-KEY-HERE with the Google Maps API Key you created in step #1), then Save.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=YOUR-GOOGLE-MAPS-API-KEY-HERE" type="text/javascript"></script>
    <script type="text/javascript">
    var map = null;
    var geocoder = null;
    var address = "{!Account.BillingStreet}, {!Account.BillingPostalCode} {!Account.BillingCity}, {!Account.BillingState}, {!Account.BillingCountry}";
    function initialize() {
    if (GBrowserIsCompatible()) {
      map = new GMap2(document.getElementById("map_canvas"));
      map.addControl(new GSmallMapControl());
      geocoder = new GClientGeocoder();
      geocoder.getLatLng(
        address,
        function(point) {
          if (!point) {
            document.getElementById("map_canvas").innerHTML = address + " not found";
          } else {
            map.setCenter(point, 13);
            var marker = new GMarker(point);
            map.addOverlay(marker);
            marker.bindInfoWindowHtml("{!Account.Name}");
          }
        }
      );
    }
    }
    </script>
    </head>
    <body onload="initialize()" onunload="GUnload()">
    <div id="map_canvas" style="width:100%;height:300px"></div>
    </body>
    </html>
    
  3. Next, navigate to Setup > Customize > Accounts > Page Layouts and click on Edit next to the correct page layout (you might only have one). Click on Create New Section with Name “Google Maps”, “Single” Columns, leave the two checkboxes checked and click Ok.
    Now, on the right hand side of the screen, from the View dropdown list, select Custom S-Controls; you’ll see the newly created S-Control (e.g.: “Inline GMaps”) and all you need to do is to drag and drop that component into the newly created section.
    Lastly, double-click on the S-Control component now in the section: a popup window will appear. Make sure the Width (in pixels or %) is 100%, set the Height (in pixels) to 300 and untick both the underneath checkboxes.
  4. All done! :) Navigate to one of your Account records and verify the map is displaying correctly!

I’m not going to analyse the S-Control line by line, with a little knowledge of HTML and JavaScript you should be able to modify it to suit your needs, but please let me know if you have any issues.

Page 1 of 41234»