Salesforce Learning Guide

Tuesday 18 November 2014

Introduction about Cloud Computing

“What’s the cloud?”  “Where is the cloud?”  “Are we in the cloud now?!” These are all questions you’ve probably heard or even asked yourself. Now new trend in IT is Cloud computing.

In the simplest terms, cloud computing means storing and accessing data and programs over the Internet instead of your computer’s hard drive. 

What cloud computing is not about is your hard drive. When you store data on–or run programs from the hard drive, that’s called local storage and computing. Everything you need is physically close to you, which means accessing your data is fast and easy (for that one computer, or others on the local network). Working off your hard drive is how the computer industry functioned for decades and some argue it’s still superior to cloud computing, for reasons I’ll explain shortly.

The cloud is also not about having a dedicated hardware server in residence. Storing data on a home or office network does not count as utilizing the cloud.

For it to be considered “cloud computing,” you need to access your data or your programs over the Internet, or at the very least, have that data synchronized with other information over the Net. In a big business, you may know all there is to know about what’s on the other side of the connection; as an individual user, you may never have any idea what kind of massive data-processing is happening on the other end. The end result is the same: with an online connection, cloud computing can be done anywhere, anytime.

Cloud Computing

Life before cloud computing

Traditional business applications have always been very complicated and expensive. The amount and variety of hardware and software required to run them are daunting. You need a whole team of experts to install, configure, test, run, secure, and update them.
When you multiply this effort across dozens or hundreds of apps, it’s easy to see why the biggest companies with the best IT departments aren’t getting the apps they need. Small and mid-sized businesses don’t stand a chance.

Cloud computing: a better way

With cloud computing, you eliminate those headaches because you’re not managing hardware and software—that’s the responsibility of an experienced vendor like salesforce.com. The shared infrastructure means it works like a utility: You only pay for what you need, upgrades are automatic, and scaling up or down is easy.
Cloud-based apps can be up and running in days or weeks, and they cost less. With a cloud app, you just open a browser, log in, customize the app, and start using it.
Businesses are running all kinds of apps in the cloud, like customer relationship management (CRM), HR, accounting, and much more. Some of the world’s largest companies moved their applications to the cloud with salesforce.com after rigorously testing the security and reliability of our infrastructure.
As cloud computing grows in popularity, thousands of companies are simply rebranding their non-cloud products and services as “cloud computing.” Always dig deeper when evaluating cloud offerings and keep in mind that if you have to buy and manage hardware and software, what you’re looking at isn’t really cloud computing but a false cloud.

Characteristics of Cloud Computing

On-demand: Resources should be always available when you need them, and you have control over turning them on or off to ensure there’s no lack of resource or wastage happen.
Scalable: You should be able to scale (increase or decrease the resource) when necessary. The cloud providers should have sufficient capacity to meet customer’s needs.
Multi-tenant: Sometimes you may be sharing the same resource (e.g. hardware) with another tenant. But of course, this is transparent to the customer. Cloud provider shall responsible the security aspect, ensuring that one tenant won’t be able to access other’s data.
Self-service computation and storage resource: Related processes including: billing, resource provisioning, and deployment should be self-service and automated, involving much less manual processing. If a machine where our service is hosted fails, the cloud provider should be able to failover our service immediately.
Reliability:  Cloud provider should be able to provide customer reliability service, committing to uptimes of their service.
Utility-based subscription: You will pay the cloud provider as a utility based subscription, just like paying your electricity bill – without any upfront investment.

Service models in cloud computing

1.       Infrastructure as a service (IaaS)
2.       Platform as a service (PaaS)
3.       Software as a service (SaaS)
4.       Network as a service (NaaS)

Services
Service Models in cloud computing

Cloud computing Types

A public cloud is one based on the standard cloud computing model, in which a service provider makes resources, such as applications and storage, available to the general public over the Internet. Public cloud services may be free or offered on a pay-per-usage model.
A private cloud is designed to offer the same features and benefits of public cloud systems, but removes a number of objections to the cloud computing model including control over enterprise and customer data, worries about security, and issues connected to regulatory compliance.
A hybrid cloud is a composition of at least one private cloud and at least one public cloud. A hybrid cloud is typically offered in one of two ways: a vendor has a private cloud and forms a partnership with a public cloud provider, or a public cloud provider forms a partnership with a vendor that provides private cloud platforms.
Cloud Computing Types
Following are list of salesforce(Cloud computing Training) materials.

1. To view basic fundamental Salesforce (Cloud computing Training) Material click following link.

Salesforce Fundamentals (Force.com Platform Fundamentals)

2. To know the Sales force editions and Pricing details See the following link.

Salesforce-editions-and-Pricing

3. To know more about Salesforce(Cloud computing Training) Material see the following links.

Salesforce Development Life Cycle

Salesforce Apex code developers guide

Salesforce visual force developers guide
Model view controller (MVC) is a software architecture pattern which separates the representation of information from the user’s interaction with it.

In addition to dividing the application into three kinds of components, the MVC design defines the interactions between them.

A controller can send commands to its associated view to change the view’s presentation of the model (e.g., by scrolling through a document). It can also send commands to the model to update the model’s state (e.g., editing a document).

A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands. A passive implementation of MVC omits these notifications, because the application does not require them or the software platform does not support them.

A view requests from the model the information that it needs to generate an output representation.

Model View Controller (MVC)
Model View Controller (MVC)

SFDC MVC: You can write your VIEW pages using SFDC visual force (VF pages). VF pages are similar to our JSP pages.  Each VF page is associated with a Controller. you can make use to already built Standard controllers or you can write your own controller using Apex language. Apex is OO and very much similar to our JAVA. you can also write Model Classes using Apex.

Visualforce uses the traditional model-view-controller (MVC) paradigm, with the option to use auto-generated controllers for database objects, providing simple and tight integration with the database. You can write your own controllers, or extensions to controllers, using Apex Code. Visualforce also provides AJAX components, and embeds the formula expression language for action, data and component binding interaction.

Salesforce.com is award winning tool to manage all the data of sales team of an organization. The flexibility and assurance of safe data provided by Salesforce.com results into nonparallel development capabilities to the developer.
SFDC MVC pattern contains below three modules:
  1. Model
  2. View
  3. Controller
Model: What schema and data does salesforce uses to represent the system completely. In salesforce, we can say that sObjects are the model as every entity in salesforce is mapped to some sObject.
View: How the schema and data is represented. Visualforce is used to present the data to users.
Controller: How the interface actions. Controllers are used to perform the actions whenever users interact with visual force.
In SFDC
1. Visual Force pages, Page Layouts, Tabs comes under View Layer of Model View controller .
2. Workflows, Apex Classes, Triggers comes under Controller part in Model View controller .
3. Objects, Fields, Relationships comes under Model Layer of Model View Controller .

Using VLOOKUP function in validation rules

What is the purpose of VLOOKUP function? It searches an object for a record where specified field matches the specified lookup value. If a match is found, returns another specified value.

Syntax of vlookup:
VLOOKUP(field_to_return, field_on_lookup_object, lookup_value)
Here I will give a simple example, how to use VLOOKUP function in validation rule.
Example: Create validation rule that checks the “Billing ZIP/postal code” entered against a table to validate that the zip code and state match.

To track ZIP Codes I have created custom object called “Zip Code” in this object I am storing zip code, states & countries. And created below records (sample records) in this zip codes object.
ZIP Code State City
35004 Alabama Moody
35005 Alabama Adamsville
35010 Alabama Alexander City
90001 California Los Angeles
Below validation rule validate Billing zip/postal code in account object with the codes in zip code object. If you enter wrong zip code this validation rule throw an error.

Creating validation rule:
To create validation rule go to setup -> Build -> Customize -> Account -> Validation rule and enter required information.

Error condition formula:
VLOOKUP($ObjectType.Zip_code__c.Fields.State__c, $ObjectType.Zip_code__c.Fields.Name , LEFT( BillingPostalCode ,5))<> BillingState
See the below image for reference.
VLOOKUP
How to test this validation rule?
To test this validation rule go to Account tab and create new account record with enter billing city = Los Angeles, Billing State/Province = Califirnia and postal code = 3099 and save this record, you will get associated error message. If you enter correct data which is mentioned in above table, record will save. If you enter wrong data validation rule will fire an error.

See the below image for reference.
VLOOKUP

Working with Salesforce Chatter:

What is Salesforce chatter? Chatter in salesforce allows you to collaborate the people with each other in your organization. You can connect with your coworkers and you can share information securely in real time. You can create groups like Facebook groups such public groups and private groups and you can invite your coworkers to join those groups by using salesforce chatter. And also you share your comments, add images and you can like others comments/posts.

By default Salesforce chatter is enabled now in Salesforce (Organizations created after 22nd June 2010). If this is not enabled to your organization and if you want to enable this setup follow below steps.
Make sure that you have “Customize application” user permission to do this setup.
1. Login to Salesforce.
2. Setup -> Customize -> chatter -> settings and ‘enable’ chatter under chatter settings and save.
See the below screen for reference.
Salesforce Chatter
Once you enabled chatter, by default Global header will be enabled to your organization. And also by default you may fallow few users and records.
By enable chatter few additional profile permissions will come at profile/permission set level. Those are

App Permissions:
Salesforce Chatter: When you enable this functionality automatically this application permission will be enabled for all your profiles in slaesforce. If you don’t want to give this application permission to some profiles, you can disable this permission.

Tab Permission:
Chatter : When you enable chat functionality, this tab will automatically enable (default on) to all profiles in your organization. If you don’t want display this to some profiles you can hide this tab.

Administrative permissions: Chatter Internal User, Create and Own New Chatter Groups, Invite Customers to Chatter, Moderate Chatter, and Manage Chatter Messages.

General User permissions: Create and Share Links to Chatter Files, Insert System Field Values for Chatter Feeds.

Important notes when you enable chatter in salesforce:
- After enabling this you will see new look and feel. Global header will enable there you can search your sobject records, chatter feeds, Groups and users.
- All users will automatically fallow when you enable this for organization with 15 or fewer users.
- This functionality is automatically available for salesforce1 apps when you enable in your org.
- Few standard publisher action available when  enable this. And also you can create your own publisher actions.

There are many more interesting things about salesforce chatter. See reference to more about salesforce chatter.

Chatter Groups

What is a chatter groups? What type of chatter groups we can create? Groups allow collaborate with specific set of people. Many of you know about groups in Facebook. In Facebook you can create groups and you can invite your friends as a members. The same type of groups you can create in salesforce chatter groups and you can invite members to that group. We can create public and private chatter groups.
Public Group: In public groups every one can join and every one can see, add post, add files & add comments.

What public group members can do in public groups: Public chatter group Members can change email settings, they can invite people and they can leave the group.

If you are the public group the owner, if you are a public chatter group owner, you can add/remove group members, you can change the group photo, you can edit group settings like information section and description section and you can change member roles.

Private Group: In private groups only members can see add posts, comments and files. And also Group admin/Owner approval must to join in private groups. People who is having modify all permission at profile/permission set level  can see post, updates, and files, and they can join private groups directly.
What private group members can do in private groups: Private chatter group Members can change email settings, they can invite people and they can leave the group.

If you are the private group the owner, If you are a owner of private chatter group you can add/remove group members, you can change the group photo, you can edit group settings like information section and description section, you can change member roles and  you can accept/decline group member request.

Creating Chatter Group: 
To create chatter group user should have “Create and Own new chatter groups” user permission required at profile/permission set level.

To create chatter group login to salesforce -> click on chatter tab -> click on Groups and click on New Group. See the below screen for reference.
Chatter Group
After clicks on new group and enter required details and save it. See the below screen for reference.
Chatter Group
While creating groups you have to enter
1. Basic information like Group name, description and Archive settings.
2. Group access settings like Public and Private and save. After creating group, members/owners can see/edit group settings like email settings, information, description they can invite members to the group. And also publisher actions available those are marked in red color in below image and also you can share your posts. See the below screen for reference.
chatter group

Adding multiple records:

Generally by using standard salesforce tab you can enter only one record at a time form UI. I don’t want to enter single record at a time. I want to enter multiple records at time. How can we achieve this? We can achieve this by using simple visual force page.
Example: I want to enter multiple accounts in single  save. See the below visualforce page.

Visualforce page:
<apex:page Controller=”AddmultipleAccountsController”>
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value=”{!listAccount}” var=”acc”>
<apex:column headerValue=”Account Name”>
<apex:inputField value=”{!acc.Name}”/>
</apex:column>
<apex:column headerValue=”Account Number”>
<apex:inputField value=”{!acc.AccountNumber}”/>
</apex:column>
<apex:column headerValue=”Account Type”>
<apex:inputField value=”{!acc.Type}”/>
</apex:column>
<apex:column headerValue=”Industry”>
<apex:inputField value=”{!acc.Industry}”/>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton value=”Add Accounts Row” action=”{!addAccount}”/>
<apex:commandButton value=”Save Accounts” action=”{!saveAccount}”/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

Controller related to above page:
public class AddmultipleAccountsController {
Account account = new Account();
public list<Account> listAccount{ get; set; }
public AddmultipleAccountsController()
{
listAccount=new list<Account>();
listAccount.add(account);
}
Public void addAccount()
{
Account acc = new Account();
listAccount.add(acc);
}
public PageReference saveAccount() {
for(Integer i=0; i<listAccount.size(); i++)
{
insert listAccount;
}
return Page.Allaccountssaved;
}
}
Visualforce page Allaccountssaved( using this page above controller):
<apex:page sidebar=”false” showHeader=”true”>
<center><h3>Congrtas your accounts are successfully saved!!</h3></center>
</apex:page>

Output of above example:
Multiple records
Here Add Account row is used to enter one more account and Save Account is used to save all account records you entered. See below screen, you can understand functionality of Add Account Row button.
Multiple
After saving you will get below screen.
Multiple 3
This is simple example to explain how to enter multiple records at time form UI.

Object Permissions

What is object permissions? In salesforce we can provide permissions to object at profile/permissions sets level. Object level we can provide read, create, edit, delete, view all & Modify all permissions in profiles/permission sets.

Read: Users can only read/view records.
Create: Users can read & create records.
Edit: Users can read & Edit.
Delete: Users can read, Edit & delete records.
View All: Users can view all records in the object irrespective of sharing settings.
Modify All: Users can read, edit, delete, view all & modify all (can transfer, approve) irrespective of sharing settings.

Above 6 permissions we can set at object level in profile/permission set. Read, Create, Edit, Delete respects sharing settings. But View all & Modify all overrides sharing settings.

Navigation to provide object permissions

Setup -> Administer -> Manage Users -> profiles -> select the profile you want give object permissions and go to object permissions and provide required object permissions to profile. See the below screen for reference.
Object Permissions

Field Level Security (FLS):

What is Field level security (FLS)? At object level we can give permission on what user can with salesforce record like user can read, create, edit, delete, view all & modify all. Object permissions we can give at object level. Now i want to restrict few sensitive fields form my users. I don’t want display these sensitive fields for all users. We can restrict fields by using field level security.

We can give read & edit permissions to the field. We can handle these filed level permissions in three ways.
1. By using “set field level security” button at field level.
2. By using “view field accessibility” button at field level
3. In profiles/permission sets we can handle field level permissions.

How can we provide filed level security?
Now in Account object object i don’t want to display revenue filed for all profiles in salesforce organization. For few profiles i want give visible permission , For few profiles i don’t want display this filed and for few profiles i want to give both visible and edit permissions. So how many ways we can achieve this? We can achieve this  two ways first is from filed and second one is from profile.

1. Field level security by using set field level security button:
Go to the filed you want to enable field level permissions and click  on Set field level security button. See the below screen for reference.
Field level security
After clicking field level security button, there you can enable that field for profiles you want give access and save settings. See the below screen for reference.
FLS2
If you enable only visible check box, then user can read & edit that field. If you enable both visible & read only, then user can only see that field, he can edit.

2. By using view field accessibility button.
Go to the filed you want to enable field level permissions and click  on view field accessibility button. then you will navigate to below screen.
Field level Security
Here you can field accessibility options. Here we can manage field viability for profiles and page layouts. You can select fields in field access for field list view. If you want enable/disable permission click hyper link editable/hidden, you will get below screen.
Filed level security 
here you can select filed level security at profile level and you can select page layout options also.

3. Managing Field level security at profile level
To handle Field permissions go to profile you want choose and go to Field level security section and search for object you want enable field permissions, click on view and edit and provide permissions for required fields and save.
Field level security
Note: In profiles you can find Field level security section on profile detail page. You cannot find  Field permission on profile edit page.

What is viewState?

ViewState holds state of the visualforce page that holds state that includes the fields, components and controller state. Viewstate data in encrypted and cannot be viewed tools like firebug.
To maintain state in a Visualforce page, the Force.com platform includes the state of components, field values, and controller state in a hidden form element. This encrypted string is referred to as the view state and has a limit of 135KB.

The data in the viewstate should be sufficient to recreate the state of the visualforce page when the postback is received. To do this, viewstate stores:

- Stores Non transient data members in the associated controller (standard\custom) and controller extensions.
- Stores Objects that are reachable from a non-transient data member in a controller or extension.
-  Stores the component tree for that page, that tree represents the visualforce page’s component structure and the associated state, which are the values applied to those components.
- view state stores small amount of data.

How to see view state:
You can see view state when developer mode is enabled. See below screen.
ViewState

Rendering visualforce page as a pdf

How can you rendering vf page as a pdf? By using renderAs attribute you can render visualforce page as a pdf.
Where we can use renderAs attribute? We can use renderAs attribute in apexPage tag like below.
<apex:page  StandardController=”Account ” renderAs=”pdf”>
Below is simple code to rendering a visualforce page as pdf.
<apex:page renderAs=”pdf”>
<center>
<h1>Welocome to Salesforce Tutorial</h1>
</center>
</apex:page>
Below is the output for this.
RenderingAs

Force.com IDE

What is Force.com IDE? It is powerful tool, which is used to create/modify & deploying Salesforce applications.

How to install force.com IDE?
1. Install Java SE Development kit (JDK), Runtime environment – Force.com plug in will fail to load if you don’t have the full Java JDK.
2. Install eclipse.
3. After installing eclipse, launch eclipse and go to help and click on install software.
Foce.com IDE insallation
4. Click on add, in the add repository dialog window, set the name to “Force.com IDE” and give location to” http://media.developerforce.com/force-ide/eclipse42”. (This URL is for eclipse 4.2 & 4.3).   Click on OK.
Force.com Ide Installation 2
5. If you don’t have latest version of the software (java & eclipse), then clear the first checkbox the above screen details section. You will get all available versions of force.com IDE plug-ins & select the check box next to the force.com plug-in you want to install and click on next.
6. And click on next & accept terms and conditions and click on finish.
7. Eclipse downloads and installs the Force.com IDE and any other required dependencies. When install complete, you will be prompted to restart. Click yes.
8. When Eclipse restarts, select Window > Open Perspective > other, select Force.com and click OK.
Now you are ready to develop & customize Force.com applications in Eclipse. Use proxy settings when are working in secured networks. You can find this in General -> Network connection

Using force.com IDE

Using force.com IDE is very simple. How to create a simple project by using this tool?
1. Open Eclipse and go to file -> click on new and select force.com project & enter your project name and credentials.
How to use force.com IDE
2. After logging in, you can select metadata components to download.
How To Use Force.com IDE 2
3. After selecting metadata components click on finish. You will get all your selected metadata into your workspace. See below screen for reference.
How To Use Force.com IDE 3
4. How can I get latest changes from force.com server to IDE?
Go to components extracted from server earlier and right click and click on refresh from server to get latest changes to IDE.
Click on save to server to save latest changes from force.com IDE to server.
To deploy you changes from one org to other org click on deploy to server option.
How To Use Force.com IDE 4
This tool is very good tool to develop application in salesforce. We can deploy metadata changes and many more we can do by using this. After using this tool you will learn all features of this tool.

Standard Controllers

A StandardController object that is automatically provided for standard and all custom objects, bindable to a Visualforce page component with the “standardController” attribute. It provides a reference to a single/list of record to a set of common actions for data processing and default navigation.

What are the tasks of standard controller?
Standard controllers provides ability to access and interact with structured business data contained in records displays in the proper user interface.

Standard controller tasks: controlling data, controlling actions and controlling navigation.

Controlling Data:

Standard controllers fetches data and provide to the views such as page, list, dialog or forms.
Controlling data for a single record: One of the key functionality of standard controllers is to provide the data, and to facilitate binding a view’s controls to the records fields for either display or input. We can associate a standard controller with a visual force page by using “StandardController”  attribute.
<apex:page standardController=”Account”>                // standard object
<apex:page standardController=”customer__c”>        
// custom object
By using merge expressions we can add fields to visualforce pages. This is the same merge syntax used in email templates, formulas and any place that field values need to be merged for expression evaluation. Below highlighted blue color syntax are merge fields
<apex:outputField value="{!Account.Name}"/>
<apex:outputField value="{!Account.AccountNumber}"/>
<apex:inputField value="{!Account.Industry}"/>
<apex:inputField value="{!Account.Type}"/>
See the below syntax to represent represent related parent object fields.
<apex:inputField value="{!Account.Owner.Name}"/>
We can represent a related list in visualforce page by using below syntax.
<apex:relatedList list="Contacts"/>
To view output, after developing your page , you need to pass related sobject record id with your salesforce url. see below example.
https://c.apX.visual.force.com/apex/vfpage?id=XXXXXXXXXXXXXXX

Controlling data for list of records: 
We can manage list of records by using standard controller instruction set. We can define recordsetVar by using below syntax.
<apex:page standardController="Account" recordSetVar="accounts">
Standard controllers provide below additional actions for list of records.
First: Displays the first page of records in the set.
Second: Displays the last page of records in the set.
Next: Displays the next page of records in the set.
Previous: Displays the previous page of records in the set.

Controlling Actions & Navigation:
Actions: Standard controller responds to to user or programmatic commands initiated from a view such as “buttons & custom links.

There are two types of actions available on objects through standard controllers instruction set.
Stateful Actions: Direct binding to a standard controller instance referenced by the page.
Stateless Actions: Indirect binding to the standard controller instruction set of the force.com engine. 

Navigation: Standard Controllers navigate the user to any specific view associate with an action. 

What is Standard List Controllers?

By using standard standard list controllers we can manage set of records. For every standard controller there exists a standard list controller that allows you to create pages that display and act on a set of records, such as list pages, related lists, and mass action pages. We can associate define standard list controller by using recordSetVar.

<apex:page standardController="Account" recordSetVar="accounts">
 
Standard list controller provides additional four pagination actions. Those are first, last, next and previous.

We can use standard list controllers with the following objects.
Account, Asset, Campaign, Case, Contact, Contract, Idea, Lead, Opportunity, Order, Product2, Solution, User, Custom Objects.

Standard list controller example:
<apex:page standardController="Account" recordSetVar="accounts">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!Accounts}" var="a">
<apex:column headerValue="Account Name">
<apex:outputField value="{!a.name}"/>
</apex:column>
</apex:pageBlockTable>

<!-- pagination actions supported by standard list controller -->
<apex:pageBlockButtons >
<apex:commandButton value="First" action="{!first}"/>
<apex:commandButton value="Last" action="{!last}"/>
<apex:commandButton value="Next" action="{!next}"/>
<apex:commandButton value="previous" action="{!previous}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>