Force.com Programming for all - A Starter's guide

3:51 AM

What is this about?

It has been a long time since i wrote an article which gave me enough satisfaction. As i was thinking, this topic came to my mind. People who are new to Salesforce find it difficult to understand the technical build-up of Salesforce, people already in Salesforce administration find it difficult to get into the programming side of Salesforce.

It was the same with me too. But, later on after browsing through many blogs, guides and some good training sessions i think i am in a comfortable position now. Hence, this article is a composition of all that.

Salesforce.com Architecture:


I have always seen myself getting fixed to a strict style of programming, even when there is an alternate easy way. So, please don't get fixed to such mindset (I've been too lazy to learn new methods). Before we get into programming further, its always good to understand the architecture.

The architecture presented below is what i heard from people and my own assumptions (not guaranteed to be 100% true).



So, your Sobject tables are not actually database tables. All Standard and Custom objects are actually VIEWS of the actual table. This is the reason you cannot have a "Select *" on your SOQL Queries.

Having said this, you may imagine how complex it would be to maintain such views, to maintain the field types, security etc etc. This is where Salesforce excels and other on-demand CRM's lack.

 Salesforce.com Point and Click Customization:

If i remember correctly, until the mid of 2007 Visualforce did not exist and all Salesforce customization was done using point and click customizations like Workflows, object and field creation, page layouts, record types, approval processes etc. These do not require that you possess programming skills. The only part which required programming skills was Apex triggers, Apex Classes and S-controls. Even though these were powerful technologies, they were not used extensively until the advent of Visualforce.

Force.com Programming:

Developing applications using Visualforce, Apex Classes, Apex Triggers is collectively called Force.com programming.  Because of the greater reach of Salesforce.com and its extensibility, it has become necessary that Salesforce.com Administrator's learn force.com programming. This helps to keep with the rapid pace of technological growth.

Why was Visualforce Introduced:

S-controls were mostly doing the job what Visualforce does now. S-controls were designed using HTML and Javascript. S-controls were used for building extensive customizations which were not available out-of-the-box.
But S-controls had their own disadvantages.
  • S-controls run on the client-side. Meaning that your code executes on your machine and not on Salesforce.com servers.
  • All your User Interface and the actions associated with them are not seperated. HTML (UI) and Javascript (actions) are in a single page. This lead  to complex pages which were hardly understandable by people other than the original developer.
So, to eliminate these disadvantages Visualforce was introduced. Visualforce (UI) and Apex Controllers (Actions) gave developers more clarity and the ability to distinguish the UI from the backend actions. This also promotes re-usability of code.

Visualforce:

We will start with Visualforce, because as you start learning Visualforce you will learn Apex Classes as well.

Visualforce is a Mark-up Langauage. Much like HTML. A Mark-up Language is one that is composed of tags. For ex: (<html></html>)is a tag. Note that when you open a tag you will have to close it with the / sign. Some tags are self-closing meaning that they can be closed in the same tag in which they are open ( for ex: <br/>)

Visualforce defines the UI (User Interface) of your application. So, you may add tables, forms, text boxes, buttons, colors, styles etc using Visualforce tags. Let's start by creating a new visualforce page. Before that you will have to enable yourself for Visualforce development like shown below.





Go to your URL bar and type http://yoursalesforceinstance.com/apex/myfirstvfpage . (Note that yoursalesforce instance is specific for you like cs3.salesforce or na1.salesforce etc) You will be shown a message that the page does not exist. Click n the create link. The page would be created and some sample code would be generated. Just delete the code and paste the code shown below in the editor.

Save the Page

<apex:page sidebar="false">
<apex:form>
    <apex:sectionHeader title="My first Visualforce Page"/>
    <apex:pageblock>
        <apex:pageblocksection title="My first form" columns="1">
          <apex:pageblocksectionitem>
            <apex:outputlabel value="Enter your name"/>
            <apex:inputtext/>
          </apex:pageblocksectionitem>  
        </apex:pageblocksection>
    </apex:pageblock> 
</apex:form>           
</apex:page>

You have seen too much of these examples rite. OK, let's see a video. Believe me, you wont be seeing the ordinary stuff. Even if you have experience on working with Visualforce, this video might teach you something new.

Comments Welcome!!

Note: The video quality is very poor. I would be soon uploading one with good quality. 




Part - TWO

2 comments