SlideShare a Scribd company logo
Getting Started with SalesForce CRM
Apex Code fundamentals Guide Part I
Description:
BISP is committed to provide BEST learning material to the beginners and advance learners.
In the same series, we have prepared a complete end-to end Hands-on Beginner’s Guide for
SalesForce. The document focuses on writing Apex code. Join our professional training
program and learn from experts.
History:
Version Description Change Author Publish Date
0.1 Initial Draft Chandra Prakash Sharma 4th
July 2013
0.1 Review#1 Amit Sharma 4th
July 2013
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 1
Contents
Apex classes in SalesForce..............................................................................................................3
How to Add an Apex Class:............................................................................................................3
Apex Triggers in SalesForce..............................................................................................................5
Triggers:.....................................................................................................................................5
How to write Trigger in SalesForce.com :...................................................................................6
How Do VisualForce Pages Compare to S-Controls?........................................................................9
Creating a VisualForce Component...................................................................................................9
What are Custom Components :.................................................................................................9
Using Custom Components in a VisualForce Page:...................................................................9
How to Defining Custom Components :....................................................................................10
What is VisualForce.....................................................................................................................10
Why use VisualForce :..............................................................................................................11
How To Create VisualForce Page ...........................................................................................11
................................................................................................................................................13
Using the VisualForce Component Library .....................................................................................13
Overriding an Existing Page with a VisualForce Page.....................................................................14
Redirecting to a Standard Object List Page.....................................................................................16
Using Input Components in a Page.................................................................................................17
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 2
Apex classes in SalesForce
In SalesForce Force.com Apex Code is an object oriented programming language that allows
developers to develop on-demand business applications on the Force.com platform.
Define a class, specify the following :
1. Access modifiers :
 You can use access modifiers public or global in the declaration of a top-level class.
 Do not use an access modifier in the declaration of an inner class.
2. Optional definition modifiers (such as virtual, abstract, and so on)
3. Required : The keyword class followed by the name of the class
4. Optional extensions:
Following syntax for defining classes:
private | public | global
[virtual | abstract | with sharing | without sharing | (none)]
class ClassName [implements InterfaceNameList | (none)] [extends ClassName | (none)]
{
//Body of the class
}
How to Add an Apex Class:
Setup > Developer > Apex classes, there is many option. you can see below.
Developer Console : In Salesforce.com developer Console is an integrated development
environment with a collection of tools you can use to create, debug, and test applications in your
SalesForce organization.
New : Click on New button open new page on this page you can write Apex code here.
Generate From WSDL : To access the Force.com Web service, you need a Web Service
Description Language (WSDL) file. The WSDL file defines the Web service that is available to you.
Your development platform uses this WSDL to generate an API to access the Force.com Web
service it defines.
Run All Tests : Click on Run All tests button for run all files.
Schedule Apex : you can schedule Apex code by using Schedule Apex button.
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 3
For create new Apex code click on New button .
Click on New button, After that open new web page on this page Apex Code editor is available. you
can see below. Write here Apex Class after then click on Save button.
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 4
Schedule Apex : Schedule an Apex class that implements the 'Schedulable' interface to be
automatically executed on a weekly or monthly interval.
Click on Schedule Apex button.
Apex Triggers in SalesForce
Triggers:
Apex can be invoked through the use of triggers. A trigger is executes before or after the following
types of operations:
 insert
 update
 delete
 upsert
 merge
 undelete
Triggers can be divided into two types :
Before triggers can be used to update or validate record values before they are saved to the
database.
Triggers can be used to access field values that are set by the database, For Example record's Id or
lastUpdated field, and to affect changes in other records, such as logging into an audit table or firing
asynchronous events with a queue.
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 5
Trigger Context Variables :
Variable Usage
isInsert Returns true if this trigger was fired due to an insert operation, from the
SalesForces user interface, Apex, or the API.
isUpdate Returns true if this trigger was fired due to an update operation, from the
SalesForce user interface, Apex, or the API.
isExecuting Returns true if the current context for the Apex code is a trigger, not a
VisualForce page, a Web service, or an executeanonymous() API call.
isDelete Returns true if this trigger was fired due to an delete operation, from the
SalesForce user interface, Apex, or the API.
isBefore Returns true if this trigger was fired before any record was saved.
isAfter Returns true if this trigger was fired after all records were saved.
isUndelete Returns true if this trigger was fired after a record is recovered from the
Recycle Bin (that is, after an undelete operation from the SalesForce user
interface, Apex, or the API.)
new Returns a list of the new versions of the sObject records.
newMap A map of IDs to the new versions of the sObject records.
old Returns a list of the old versions of the sObject records.
oldMap A map of IDs to the old versions of the sObject records.
size The total number of records in a trigger invocation, both old and new.
How to write Trigger in SalesForce.com :
Setup > Develop > Apex Triggers, Click on Developer Console button. open new web page. You
can see below. For create Apex Trigger click on File > New > Apex Trigger.
After that open popup window in this window, Write Trigger name and select Object class (which
you need to bind with trigger) then click on submit button. Then you can see new page for write new
trigger.
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 6
After Write trigger , go to File menu and click on Save see below .
also you use CTRL + S by using keyboard.
Note : For understanding Apex Classes or Apex Trigger you can see
here.
Example , see below .
Example : Write apex code for automatically increasing 2% on the submit fees for every student.
Step 1 : Create any custom object tab. For Ex : College you can see below.
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 7
Step 2 : After then go to adding Apex code, Setup > Developer > Apex classes, click on New
button.
then write here Apex code.
Step 3 :
After write Apex classes , Write Apex Trigger Click on Apex Trigger for write Apex Trigger.
Step 4 : After that Save fees, then see fees increase 2% .
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 8
How Do VisualForce Pages Compare to S-Controls?
S-Controls, is older Force.com technology that has now been superseded by VisualForce, still
function on Force.com. You can continue to use existing S-Controls, but restrictions are being
placed on creating new ones.
Creating a VisualForce Component
Salesforce.com provides a library of standard, pre-built components, such as <apex:page
renderAs="pdf">, <apex:tabPanel > and <apex:dataTable>, that can be used to develop
VisualForce pages. In addition, you can build your own custom components to augment this library.
What are Custom Components :
In custom components you can reuse that method several times in a program, you can encapsulate
a common design pattern in a custom component and then reuse that component several times in
one or more VisualForce pages.
Example, If you want to create a Employee list using VisualForce pages. Each Employee record in
the list has its own border. Rather than repeating the VisualForce markup required for displaying
every Employee record in the list. Once defined, standard components such as <apex:relatedList>
or <apex:dataTable> .
Using Custom Components in a VisualForce Page:
Create a new custom component named recordDisplay.
<apex:page >
<apex:pageBlock title="Employee List" >
<b> Welcome :</b> {!$User.FirstName}
<apex:detail />
</apex:pageBlock>
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 9
</apex:page>
How to Defining Custom Components :
Setup > Develop > Components, Click on New button.
Step 1 : Enter Label Name then write VisualForce Component after then click on Save button.
Step 2 : After that create new VisualForce page and write here some cod you can see below.
What is VisualForce
VisualForce is framework that allows developers to build refined, custom user interfaces that can be
hosted natively on the Force.com platform. The VisualForce framework includes a tag-based
markup language, similar to HTML.
In VisualForce page you can use html code, JavaScript, CSS, Ajax, Flesh.
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 10
Developers can use VisualForce to create a VisualForce page definition. A page definition consists
of two primary elements:
- VisualForce markup.
- A VisualForce controller.
VisualForce Markup :-
VisualForce markup consists of VisualForce tags, HTML, JavaScript, or any other Web-enabled
code embedded within a single <apex: page> tag. The markup defines the user interface
components that should be included on the page, and the way they should appear.
VisualForce Control :-
A VisualForce controller is a set of instructions that specify what happens when a user interacts
with the components specified in associated VisualForce markup, such as when a user clicks a
button or link.
Why use VisualForce :
- To create custom interfaces.
- To build wizards.
- To define custom navigation patterns.
How To Create VisualForce Page
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 11
Click on Setup > develop > Pages
Then Click on New button.
Step 1 :
After Saving this page, click on this icon to view Home page.
If you are getting error for view page, solve this problem by following some steps.Given below.
Click on Setup > Manage Users > Users then click on Edit link button for edit user settings.
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 12
Then you can find Development Mode and checked
check box then click on save button.
After then you can click on view icon that time, there is
VisualForce to ask you to create new page because this
page is open in development mode.
Second type of create VisualForce page :
go to web browser type UR L, you can see below. Ex : Http:// SalesForce link after login/apex/Page
Name
Using the VisualForce Component Library
VisualForce <apex:page></apex:page> tag is use mandatory, tag must be placed at start and end
of all VisualForce markup.
and also VisualForce supports all html tag. For example : <img src=" ">,
<table><tr><td></td></table>, <marquee></marquee> etc.
How to use VisualForce Component Library :
Just go to create new page. For example I will create Example2 . You can see below.
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 13
When you click on Component Reference link you can see new web page. On this web page all
Component with syntax are available, which Component you want to add Just write in code window.
see below.
And also see how to use Iframe in VisualForce page .
Overriding an Existing Page with a VisualForce Page
If you need to change the format of an existing page, such as the standard account detail page. All
the information displays on a single page. If there's a lot of information, you might end up doing a lot
of scrolling. Using VisualForce in a page you can make each section(Tab) for an account display in
a tab.
1. Firstly, Create a new VisualForce page using the quick fix.
/apex/PageName
For Example We create this page https://c.ap1.visual.force.com/apex/Overrding
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 14
2. Create Overriding page.
3. Delete Existing code. and paste it below code.
4. See below code.
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 15
Redirecting to a Standard Object List Page
In Salesforce.com, buttons or links that navigate a user to a standard tab, you can redirect the
content to present a list of standard objects.
Create a VisualForce page with the following markup :
Following code uses command button, see below.
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 16
After Click on this button you can see page redirect Account page. you can see below.
Using Input Components in a Page
In VisualForce you can use the <apex:form> tag with one or more input components and a
<apex:commandLink> or <apex:commandButton> tag to submit the form.
The input component tag :
 <apex:inputCheckbox>
 <apex:inputField>
 <apex:inputSecret>
 <apex:inputText>
 <apex:inputTextarea>
 <apex:outputField>
 <apex:outputText>
 <apex:selectCheckboxes>
 <apex:selectList>
 <apex:selectRadio>
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 17
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 18

More Related Content

What's hot (18)

PDF
Security and-data-access-document
Amit Sharma
 
PDF
Salesforce interview-preparation-toolkit-formula-and-validation-rules-in-sale...
Amit Sharma
 
PDF
Oracle apex-hands-on-guide lab#1
Amit Sharma
 
PDF
Salesforce interview preparation toolkit formula and validation rules in sale...
Amit Sharma
 
PDF
Apex code-fundamentals
Amit Sharma
 
PDF
User and group security migration
Amit Sharma
 
PPTX
Mulesoft salesforce connector to update Object.
Yogesh Chandr
 
PPTX
Salesforce Winter Release
Betina Meyer Pflug
 
PDF
Oracle EMC 12C Grand Tour
Rakesh Gujjarlapudi
 
PPTX
Introduction to visualforce
Rinku Saini
 
PPTX
Exploring Adobe Flex
senthil0809
 
PDF
Vbabook ed2
NilsonVallecillo
 
PDF
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
MahmoudOHassouna
 
PPT
Developing Mash up applications with Adobe AIR
marcocasario
 
PDF
Murach : How to work with session state and cookies
MahmoudOHassouna
 
PDF
Desk Sync User Installation Guide
Cloud Analogy
 
PPTX
WordPress + Office 365 | Employee directory v9.x
Marco van Wieren
 
PDF
Test script
Bharathi P
 
Security and-data-access-document
Amit Sharma
 
Salesforce interview-preparation-toolkit-formula-and-validation-rules-in-sale...
Amit Sharma
 
Oracle apex-hands-on-guide lab#1
Amit Sharma
 
Salesforce interview preparation toolkit formula and validation rules in sale...
Amit Sharma
 
Apex code-fundamentals
Amit Sharma
 
User and group security migration
Amit Sharma
 
Mulesoft salesforce connector to update Object.
Yogesh Chandr
 
Salesforce Winter Release
Betina Meyer Pflug
 
Oracle EMC 12C Grand Tour
Rakesh Gujjarlapudi
 
Introduction to visualforce
Rinku Saini
 
Exploring Adobe Flex
senthil0809
 
Vbabook ed2
NilsonVallecillo
 
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
MahmoudOHassouna
 
Developing Mash up applications with Adobe AIR
marcocasario
 
Murach : How to work with session state and cookies
MahmoudOHassouna
 
Desk Sync User Installation Guide
Cloud Analogy
 
WordPress + Office 365 | Employee directory v9.x
Marco van Wieren
 
Test script
Bharathi P
 

Viewers also liked (19)

PPTX
Introduction to apex code
EdwinOstos
 
PPTX
Apex basics-for Beginners
hrakhra
 
PPT
Salesforce Presentation
Chetna Purohit
 
PDF
Intro to Apex Programmers
Salesforce Developers
 
PPTX
Deep Dive into Apex Triggers
Salesforce Developers
 
PPTX
Apex for Admins: Get Started with Apex in 30 Minutes! (part 1)
Salesforce Developers
 
PPTX
Introduction to Apex for Developers
Salesforce Developers
 
PPTX
APEX navigation concepts
Tobias Arnhold
 
PPTX
Apex for Admins: Beyond the Basics
Salesforce Developers
 
DOCX
Interview questions
mallareddy0107
 
PPTX
Atl elevate programmatic developer slides
David Scruggs
 
PPTX
Triggers for Admins: A Five-step Framework for Creating Triggers
Salesforce Developers
 
PPTX
Hands-On Workshop: Introduction to Development on Force.com for Developers
Salesforce Developers
 
ODP
Workflow in Salesforce
MST Solutions LLC
 
PPT
What you need to know on Force.com in 10 slides
Guillaume Windels
 
PDF
Intro to Force.com Webinar presentation
Developer Force - Force.com Community
 
PPTX
Apex code (Salesforce)
Mohammed Safwat Abu Kwaik
 
PPTX
What is force.com?
Roy Gilad
 
PDF
Introduction to Git for Force.com Developers
Salesforce Developers
 
Introduction to apex code
EdwinOstos
 
Apex basics-for Beginners
hrakhra
 
Salesforce Presentation
Chetna Purohit
 
Intro to Apex Programmers
Salesforce Developers
 
Deep Dive into Apex Triggers
Salesforce Developers
 
Apex for Admins: Get Started with Apex in 30 Minutes! (part 1)
Salesforce Developers
 
Introduction to Apex for Developers
Salesforce Developers
 
APEX navigation concepts
Tobias Arnhold
 
Apex for Admins: Beyond the Basics
Salesforce Developers
 
Interview questions
mallareddy0107
 
Atl elevate programmatic developer slides
David Scruggs
 
Triggers for Admins: A Five-step Framework for Creating Triggers
Salesforce Developers
 
Hands-On Workshop: Introduction to Development on Force.com for Developers
Salesforce Developers
 
Workflow in Salesforce
MST Solutions LLC
 
What you need to know on Force.com in 10 slides
Guillaume Windels
 
Intro to Force.com Webinar presentation
Developer Force - Force.com Community
 
Apex code (Salesforce)
Mohammed Safwat Abu Kwaik
 
What is force.com?
Roy Gilad
 
Introduction to Git for Force.com Developers
Salesforce Developers
 
Ad

Similar to Apex code-fundamentals (20)

PPTX
Introduction to apex
Rinku Saini
 
PPTX
Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...
Salesforce Developers
 
DOCX
Salesforce couse in chennai
THINK IT Training
 
DOCX
Salesforce Certification in chennai
THINK IT Training
 
DOCX
Salesforce couse Training in chennai
Jessiersavage
 
DOCX
SALESFORCE TRAINING IN CHENNAI
lakshmipriyaaka
 
DOCX
Salesforce couse content
Jessiersavage
 
PDF
Salesforce Developer Online Training.pdf
SpiritsoftsTraining
 
PPTX
Elevate Tel Aviv
sready
 
PDF
Rg apexand visualforcearchitecture
CMR WORLD TECH
 
PDF
Apexand visualforcearchitecture
CMR WORLD TECH
 
PPTX
Salesforce online training -GoLogica
GoLogica Technologies
 
PDF
Ecrire son premier Trigger (et les comprendre)
Doria Hamelryk
 
PPTX
Salesforce
maheswara reddy
 
PDF
Elevate london dec 2014.pptx
Peter Chittum
 
PDF
salesforce_apex_developer_guide
BrindaTPatil
 
DOCX
Best salesforce training Institute in Hyderabad
N Benchmark IT Solutions
 
PDF
Customizing sales force-interface
Amit Sharma
 
PPTX
Force.com Friday : Intro to Apex
Salesforce Developers
 
PPTX
Apex for Admins: Beyond the Basics (Part 2)
Salesforce Developers
 
Introduction to apex
Rinku Saini
 
Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...
Salesforce Developers
 
Salesforce couse in chennai
THINK IT Training
 
Salesforce Certification in chennai
THINK IT Training
 
Salesforce couse Training in chennai
Jessiersavage
 
SALESFORCE TRAINING IN CHENNAI
lakshmipriyaaka
 
Salesforce couse content
Jessiersavage
 
Salesforce Developer Online Training.pdf
SpiritsoftsTraining
 
Elevate Tel Aviv
sready
 
Rg apexand visualforcearchitecture
CMR WORLD TECH
 
Apexand visualforcearchitecture
CMR WORLD TECH
 
Salesforce online training -GoLogica
GoLogica Technologies
 
Ecrire son premier Trigger (et les comprendre)
Doria Hamelryk
 
Salesforce
maheswara reddy
 
Elevate london dec 2014.pptx
Peter Chittum
 
salesforce_apex_developer_guide
BrindaTPatil
 
Best salesforce training Institute in Hyderabad
N Benchmark IT Solutions
 
Customizing sales force-interface
Amit Sharma
 
Force.com Friday : Intro to Apex
Salesforce Developers
 
Apex for Admins: Beyond the Basics (Part 2)
Salesforce Developers
 
Ad

More from Amit Sharma (19)

PDF
Oracle enteprise pbcs drivers and assumptions
Amit Sharma
 
PDF
Oracle EPBCS Driver
Amit Sharma
 
PDF
Oracle Sales Quotation Planning
Amit Sharma
 
PDF
Oracle strategic workforce planning cloud hcmswp converted
Amit Sharma
 
PDF
Basics of fdmee
Amit Sharma
 
PDF
FDMEE script examples
Amit Sharma
 
PDF
Oracle PBCS creating standard application
Amit Sharma
 
PPT
Hfm rule custom consolidation
Amit Sharma
 
PPT
Hfm calculating RoA
Amit Sharma
 
PPT
Adding metadata using smartview
Amit Sharma
 
PPT
Hyperion planning weekly distribution
Amit Sharma
 
PPT
Hyperion planning scheduling data import
Amit Sharma
 
PPT
Hyperion planning new features
Amit Sharma
 
TXT
Microsoft dynamics crm videos
Amit Sharma
 
PDF
Sales force certification-lab-ii
Amit Sharma
 
PDF
Sales force certification-lab
Amit Sharma
 
PDF
Managing users-doc
Amit Sharma
 
PDF
Force.com migration utility
Amit Sharma
 
PDF
User and group security migration
Amit Sharma
 
Oracle enteprise pbcs drivers and assumptions
Amit Sharma
 
Oracle EPBCS Driver
Amit Sharma
 
Oracle Sales Quotation Planning
Amit Sharma
 
Oracle strategic workforce planning cloud hcmswp converted
Amit Sharma
 
Basics of fdmee
Amit Sharma
 
FDMEE script examples
Amit Sharma
 
Oracle PBCS creating standard application
Amit Sharma
 
Hfm rule custom consolidation
Amit Sharma
 
Hfm calculating RoA
Amit Sharma
 
Adding metadata using smartview
Amit Sharma
 
Hyperion planning weekly distribution
Amit Sharma
 
Hyperion planning scheduling data import
Amit Sharma
 
Hyperion planning new features
Amit Sharma
 
Microsoft dynamics crm videos
Amit Sharma
 
Sales force certification-lab-ii
Amit Sharma
 
Sales force certification-lab
Amit Sharma
 
Managing users-doc
Amit Sharma
 
Force.com migration utility
Amit Sharma
 
User and group security migration
Amit Sharma
 

Apex code-fundamentals

  • 1. Getting Started with SalesForce CRM Apex Code fundamentals Guide Part I Description: BISP is committed to provide BEST learning material to the beginners and advance learners. In the same series, we have prepared a complete end-to end Hands-on Beginner’s Guide for SalesForce. The document focuses on writing Apex code. Join our professional training program and learn from experts. History: Version Description Change Author Publish Date 0.1 Initial Draft Chandra Prakash Sharma 4th July 2013 0.1 Review#1 Amit Sharma 4th July 2013 www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 1
  • 2. Contents Apex classes in SalesForce..............................................................................................................3 How to Add an Apex Class:............................................................................................................3 Apex Triggers in SalesForce..............................................................................................................5 Triggers:.....................................................................................................................................5 How to write Trigger in SalesForce.com :...................................................................................6 How Do VisualForce Pages Compare to S-Controls?........................................................................9 Creating a VisualForce Component...................................................................................................9 What are Custom Components :.................................................................................................9 Using Custom Components in a VisualForce Page:...................................................................9 How to Defining Custom Components :....................................................................................10 What is VisualForce.....................................................................................................................10 Why use VisualForce :..............................................................................................................11 How To Create VisualForce Page ...........................................................................................11 ................................................................................................................................................13 Using the VisualForce Component Library .....................................................................................13 Overriding an Existing Page with a VisualForce Page.....................................................................14 Redirecting to a Standard Object List Page.....................................................................................16 Using Input Components in a Page.................................................................................................17 www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 2
  • 3. Apex classes in SalesForce In SalesForce Force.com Apex Code is an object oriented programming language that allows developers to develop on-demand business applications on the Force.com platform. Define a class, specify the following : 1. Access modifiers :  You can use access modifiers public or global in the declaration of a top-level class.  Do not use an access modifier in the declaration of an inner class. 2. Optional definition modifiers (such as virtual, abstract, and so on) 3. Required : The keyword class followed by the name of the class 4. Optional extensions: Following syntax for defining classes: private | public | global [virtual | abstract | with sharing | without sharing | (none)] class ClassName [implements InterfaceNameList | (none)] [extends ClassName | (none)] { //Body of the class } How to Add an Apex Class: Setup > Developer > Apex classes, there is many option. you can see below. Developer Console : In Salesforce.com developer Console is an integrated development environment with a collection of tools you can use to create, debug, and test applications in your SalesForce organization. New : Click on New button open new page on this page you can write Apex code here. Generate From WSDL : To access the Force.com Web service, you need a Web Service Description Language (WSDL) file. The WSDL file defines the Web service that is available to you. Your development platform uses this WSDL to generate an API to access the Force.com Web service it defines. Run All Tests : Click on Run All tests button for run all files. Schedule Apex : you can schedule Apex code by using Schedule Apex button. www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 3
  • 4. For create new Apex code click on New button . Click on New button, After that open new web page on this page Apex Code editor is available. you can see below. Write here Apex Class after then click on Save button. www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 4
  • 5. Schedule Apex : Schedule an Apex class that implements the 'Schedulable' interface to be automatically executed on a weekly or monthly interval. Click on Schedule Apex button. Apex Triggers in SalesForce Triggers: Apex can be invoked through the use of triggers. A trigger is executes before or after the following types of operations:  insert  update  delete  upsert  merge  undelete Triggers can be divided into two types : Before triggers can be used to update or validate record values before they are saved to the database. Triggers can be used to access field values that are set by the database, For Example record's Id or lastUpdated field, and to affect changes in other records, such as logging into an audit table or firing asynchronous events with a queue. www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 5
  • 6. Trigger Context Variables : Variable Usage isInsert Returns true if this trigger was fired due to an insert operation, from the SalesForces user interface, Apex, or the API. isUpdate Returns true if this trigger was fired due to an update operation, from the SalesForce user interface, Apex, or the API. isExecuting Returns true if the current context for the Apex code is a trigger, not a VisualForce page, a Web service, or an executeanonymous() API call. isDelete Returns true if this trigger was fired due to an delete operation, from the SalesForce user interface, Apex, or the API. isBefore Returns true if this trigger was fired before any record was saved. isAfter Returns true if this trigger was fired after all records were saved. isUndelete Returns true if this trigger was fired after a record is recovered from the Recycle Bin (that is, after an undelete operation from the SalesForce user interface, Apex, or the API.) new Returns a list of the new versions of the sObject records. newMap A map of IDs to the new versions of the sObject records. old Returns a list of the old versions of the sObject records. oldMap A map of IDs to the old versions of the sObject records. size The total number of records in a trigger invocation, both old and new. How to write Trigger in SalesForce.com : Setup > Develop > Apex Triggers, Click on Developer Console button. open new web page. You can see below. For create Apex Trigger click on File > New > Apex Trigger. After that open popup window in this window, Write Trigger name and select Object class (which you need to bind with trigger) then click on submit button. Then you can see new page for write new trigger. www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 6
  • 7. After Write trigger , go to File menu and click on Save see below . also you use CTRL + S by using keyboard. Note : For understanding Apex Classes or Apex Trigger you can see here. Example , see below . Example : Write apex code for automatically increasing 2% on the submit fees for every student. Step 1 : Create any custom object tab. For Ex : College you can see below. www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 7
  • 8. Step 2 : After then go to adding Apex code, Setup > Developer > Apex classes, click on New button. then write here Apex code. Step 3 : After write Apex classes , Write Apex Trigger Click on Apex Trigger for write Apex Trigger. Step 4 : After that Save fees, then see fees increase 2% . www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 8
  • 9. How Do VisualForce Pages Compare to S-Controls? S-Controls, is older Force.com technology that has now been superseded by VisualForce, still function on Force.com. You can continue to use existing S-Controls, but restrictions are being placed on creating new ones. Creating a VisualForce Component Salesforce.com provides a library of standard, pre-built components, such as <apex:page renderAs="pdf">, <apex:tabPanel > and <apex:dataTable>, that can be used to develop VisualForce pages. In addition, you can build your own custom components to augment this library. What are Custom Components : In custom components you can reuse that method several times in a program, you can encapsulate a common design pattern in a custom component and then reuse that component several times in one or more VisualForce pages. Example, If you want to create a Employee list using VisualForce pages. Each Employee record in the list has its own border. Rather than repeating the VisualForce markup required for displaying every Employee record in the list. Once defined, standard components such as <apex:relatedList> or <apex:dataTable> . Using Custom Components in a VisualForce Page: Create a new custom component named recordDisplay. <apex:page > <apex:pageBlock title="Employee List" > <b> Welcome :</b> {!$User.FirstName} <apex:detail /> </apex:pageBlock> www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 9
  • 10. </apex:page> How to Defining Custom Components : Setup > Develop > Components, Click on New button. Step 1 : Enter Label Name then write VisualForce Component after then click on Save button. Step 2 : After that create new VisualForce page and write here some cod you can see below. What is VisualForce VisualForce is framework that allows developers to build refined, custom user interfaces that can be hosted natively on the Force.com platform. The VisualForce framework includes a tag-based markup language, similar to HTML. In VisualForce page you can use html code, JavaScript, CSS, Ajax, Flesh. www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 10
  • 11. Developers can use VisualForce to create a VisualForce page definition. A page definition consists of two primary elements: - VisualForce markup. - A VisualForce controller. VisualForce Markup :- VisualForce markup consists of VisualForce tags, HTML, JavaScript, or any other Web-enabled code embedded within a single <apex: page> tag. The markup defines the user interface components that should be included on the page, and the way they should appear. VisualForce Control :- A VisualForce controller is a set of instructions that specify what happens when a user interacts with the components specified in associated VisualForce markup, such as when a user clicks a button or link. Why use VisualForce : - To create custom interfaces. - To build wizards. - To define custom navigation patterns. How To Create VisualForce Page www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 11
  • 12. Click on Setup > develop > Pages Then Click on New button. Step 1 : After Saving this page, click on this icon to view Home page. If you are getting error for view page, solve this problem by following some steps.Given below. Click on Setup > Manage Users > Users then click on Edit link button for edit user settings. www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 12
  • 13. Then you can find Development Mode and checked check box then click on save button. After then you can click on view icon that time, there is VisualForce to ask you to create new page because this page is open in development mode. Second type of create VisualForce page : go to web browser type UR L, you can see below. Ex : Http:// SalesForce link after login/apex/Page Name Using the VisualForce Component Library VisualForce <apex:page></apex:page> tag is use mandatory, tag must be placed at start and end of all VisualForce markup. and also VisualForce supports all html tag. For example : <img src=" ">, <table><tr><td></td></table>, <marquee></marquee> etc. How to use VisualForce Component Library : Just go to create new page. For example I will create Example2 . You can see below. www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 13
  • 14. When you click on Component Reference link you can see new web page. On this web page all Component with syntax are available, which Component you want to add Just write in code window. see below. And also see how to use Iframe in VisualForce page . Overriding an Existing Page with a VisualForce Page If you need to change the format of an existing page, such as the standard account detail page. All the information displays on a single page. If there's a lot of information, you might end up doing a lot of scrolling. Using VisualForce in a page you can make each section(Tab) for an account display in a tab. 1. Firstly, Create a new VisualForce page using the quick fix. /apex/PageName For Example We create this page https://c.ap1.visual.force.com/apex/Overrding www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 14
  • 15. 2. Create Overriding page. 3. Delete Existing code. and paste it below code. 4. See below code. www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 15
  • 16. Redirecting to a Standard Object List Page In Salesforce.com, buttons or links that navigate a user to a standard tab, you can redirect the content to present a list of standard objects. Create a VisualForce page with the following markup : Following code uses command button, see below. www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 16
  • 17. After Click on this button you can see page redirect Account page. you can see below. Using Input Components in a Page In VisualForce you can use the <apex:form> tag with one or more input components and a <apex:commandLink> or <apex:commandButton> tag to submit the form. The input component tag :  <apex:inputCheckbox>  <apex:inputField>  <apex:inputSecret>  <apex:inputText>  <apex:inputTextarea>  <apex:outputField>  <apex:outputText>  <apex:selectCheckboxes>  <apex:selectList>  <apex:selectRadio> www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 17