Sie sind auf Seite 1von 176

What is Salesforce?

Salesforce.com is cloud
computing company
which
is
based
in San
Francisco, USA. It offers business software on a subscription basis. Salesforce also
hosts the application offsite and it is popular for its Customer Relationship
Managementproducts.
The company was founded by Marc Benioff, a former Oracle executive, Parker
Harris,Dave Moellenhoff and Frank Dominguez in March 1999. This company
then specializes in software as a service. The company went public in June 2004
on theNew York Stock Exchange under the stock symbol CRM.
salesforce.com is all about CRM. It's a site that's built for Customer Relationship
Management, this basically means they give you a resource to keep a firm base of
communication and knowledge with your customers that will help you succeed as
well as gain new customers. It is a program and part of a business plan to help you
gain knowledge about your customers and their behaviors and needs that you can
help provide to get a stronger base for your company. It gives you a great
advantage over those companies and businesses that choose not to focus on CRM
and do not keep a tab on customers and what it will take to draw in new ones.
Salesforce is a technology that is basically a cloud computing platform that will
help you with your CRM and budget everything to make your business as
successful as it can possibly be!

Trigger Life Time and Order of Execution:


When you save a record with an insert, update, or upsert statement, Salesforce performs the
following events in order.Note
Before Salesforce executes these events on the server, the browser runs JavaScript validation if the record contains any dependent picklist fields. The validation limits each dependent picklist field to its available values. No other validation occurs on the client side.
On the server, Salesforce:
1. Loads the original record from the database or initializes the record for an upsert statement.
2. Loads the new record field values from the request and overwrites the old values.
If the request came from a standard UI edit page, Salesforce runs system validation to
check the record for:
o

Compliance with layout-specific rules


1

Required values at the layout level and field-definition level

Valid field formats

Maximum field length

Salesforce doesn't perform system validation in this step when the request comes from
other sources, such as an Apex application or a SOAP API call.
Salesforce runs user-defined validation rules if multiline items were created, such as
quote line items and opportunity line items.
3. Executes all before triggers.
4. Runs most system validation steps again, such as verifying that all required fields have a
non-null value, and runs any user-defined validation rules. The only system validation
that Salesforce doesn't run a second time (when the request comes from a standard UI
edit page) is the enforcement of layout-specific rules.
5. Executes duplicate rules. If the duplicate rule identifies the record as a duplicate and uses
the block action, the record is not saved and no further steps, such as after triggers and
workflow rules, are taken.
6. Saves the record to the database, but doesn't commit yet.
7. Executes all after triggers.
8. Executes assignment rules.
9. Executes auto-response rules.
10. Executes workflow rules.
11. If there are workflow field updates, updates the record again.
12. If workflow field updates introduced new duplicate field values, executes duplicate rules
again.
13. If the record was updated with workflow field updates, fires before update triggers and after update triggers one more time (and only one more time), in addition to standard validations. Custom validation rules are not run again.
14. Executes processes.
If there are workflow flow triggers, executes the flows.
Flow trigger workflow actions, formerly available in a pilot program, have been superseded by the Process Builder. Organizations that are using flow trigger workflow actions
2

may continue to create and edit them, but flow trigger workflow actions arent available
for new organizations. For information on enabling the Process Builder in your organization, contact Salesforce.
15. Executes escalation rules.
16. Executes entitlement rules.
17. If the record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary field in the parent record. Parent
record goes through save procedure.
18. If the parent record is updated, and a grandparent record contains a roll-up summary
field or is part of a cross-object workflow, performs calculations and updates the roll-up
summary field in the grandparent record. Grandparent record goes through save procedure.
19. Executes Criteria Based Sharing evaluation.
20. Commits all DML operations to the database.
21. Executes post-commit logic, such as sending email.
Note

During a recursive save, Salesforce skips steps 8 (assignment rules) through 18 (roll-up
summary field in the grandparent record).

What is Salesforce and 5 Reasons why it is the Best CRM


CRM software solutions were offered in an on-premise delivery model 15 years
ago. Companies installed the software on their servers and maintained it inhouse. However, with the on-premise CRM, IT companies had to take on the technical responsibilities which include system design, infrastructure and server management.

This paved way for a novel kind of CRM - the Cloud based CRM. In any cloud
based CRM, applications are hosted by the vendor and organizations can gain access to data through the web without having to worry about any technical aspects
of managing it.
Cloud CRM has become popular over time upsetting the concept of the on-premise CRM model because there was no software licensing fee involved, the organization did not need dedicated IT staff or infrastructure. This has in turn reduced
the cost of monthly services and eased the set up process.
What is Salesforce CRM?
Organizations were in need of a cloud CRM to deal with all sorts of customer concerns varying from marketing and sales to customer service - to streamline the
enterprise and help in saving valuable resources and time. Salesforce as founded
in 1999 by former Oracle executive Marc Benioff, Parker Harris, Dave Moellenhoff, and Frank Dominguez - with a vision to reinvent the Cloud CRM model
and now, Salesforce defines the new era of cloud computing.
What does Salesforce do?
Salesforce is cloud based CRM software, developed to make organizations function efficiently and profitably by reducing the cost of managing hardware infrastructure. Salesforce offers a wide range of features in all the functional areas of a
company:

Salesforce in Marketing Team: Salesforce professional edition helps the marketing team of a company create and track various marketing campaigns to measure the success rate and automatically provide leads to the sales team of the company.

Salesforce in Customer Support Team: Salesforce also keeps a track of various customer issues and tracks them for resolution based on various escalation

rules such as the importance of the client and elapsed time. This improves customer satisfaction levels as the issues do not fall through loopholes and are directly escalated to the next level.

Salesforce in Management: With visual dashboards and extensive reporting


features, Salesforce provides the management of a company with visibility on
what is happening in different teams.

Salesforce in Training: Salesforce has very robust training and support features that are above industry standards. Salesforce users can easily find answers
to their questions from the extensive online help manual and the video walk facility.

Salesforce in Application Integration: Salesforce can be integrated with


other systems to extend its functionality through the Salesforce business app store
- the AppExchange.
Salesforce CRM was awarded as the Worlds Most Innovative Company by Forbes
Innovators for 4 continuous years (2011-2014). Salesforce also featured in FORTUNEs 100 Best Companies to work for in 2012-2014.
With over 2 million customers (amassed in a short while) which include popular
data giants namely Fujitsu, Facebook, Coca-Cola, LOreal, Sony, and Vodafone Salesforce CRM is truly the undisputed market leader in the CRM Software market. Integrator Bluewolf interviewed close to 450 client companies and concluded
that 84% of the enterprises believe in customer engagement as the primary key
element for future growth of the enterprise. Buyers perceive Salesforce as the platform integral for rendering qualitative customer engagement experience.
Tien Tzuo, the present CEO of Zuora and ex-CMO of Salesforce said that CRM
Software is an entry point. What we (Salesforce) are planning to be is the business
web. That means that we want to be the platform for all business apps. When a
business starts its day, they open up their apps on us and all day, all their apps are
running on our foundation.
5 REASONS WHY SALESFORCE IS THE BEST CRM
5

1. CURRENT TRENDS AND SUSTAINED GROWTH

According to Gartner, the overall value of the Global CRM Software Market was
20.4 billion USD by the end of 2013 - which is anticipated to increase by 13.7 %
every year, making the global CRM software market a billion dollar space.
Salesforce is right at the top contributing to 16% of the overall CRM Software market share, making Salesforce and CRM software inseparable.
Yvonne Genovese, Vice President at Gartners Marketing Leaders Research said
Marketing will be the largest growing Salesforce CRM category through 2017.
The International Data Corporation (or IDC) expects the overall market for marketing automation to grow from $3.2 billion in 2010 to $4.8 billion in 2015.

Image Credit: http://marketrealist.com/


According to the Gartner research reports, 94% of the Salesforce CRM revenue
generated from the Support and Subscription fees whilst only 6% of the revenue
comes from Professional Services. Salesforce is concentrating on Supports and
Subscriptions to grow its revenue exponentially.
6

Image Credit: http://marketrealist.com/


The companys CEO Marc Benioff stated that Salesforce.com has recorded constant currency and deferred revenue growth of 30% or more year-over year. The
company expects revenue to rise to between $6.45 billion and $6.50 billion in
2016.
2. VISION AND EXECUTION
With a complete long term vision and its high capability to execute, salesforce
CRM Software claims the highest position in the Customer Relationship Management software market. The ability to execute this vision on ground has helped
Salesforce reach the top.
In 2014, Gartner, once again titled Salesforce as the leading CRM software.
Salesforce has maintained this position for 4 years in a row.Salesforce has
emerged as the leader in the Gartners Leader Magic quadrant for 2014 (the image
below illustrates the leading position of Salesforce when compared to other CRM
software players).

3. STRATEGIC ACQUISITIONS
Salesforce has a smart acquisition policy to increase enhanced capabilities. As part
of their long-term vision, they were successful in numerous strategic acquisitions
from the year 2006. Strategic Acquisitions have helped the Salesforce CRM Software build highly broadened marketing eco system referred to as the Marketing
Cloud.

Image Credit: http://www.salesforceben.com


In June 2013, ExactTarget was acquired for $2.5 billion which helped enhance the
Marketing Cloud through email campaign management and marketing automation. ExactTarget acquisition has also resulted in Salesforce owning Pardot, an
application for marketing automation that primarily works in the area of online
marketing campaigns. Pardot helps boost sales by creating and deploying marketing campaigns. Pardot has a vital significance in increased revenue and efficiency
of Salesforce CRM Software.
8

The most recent strategic acquisition has been that of RelateIQ for $390 million
which helps eliminate manual data entry by automated tracking of relationships
in the CRM space. This will certainly be a critical value addition offering in
Salesforce Marketing Cloud.

Image Credit:http://marketrealist.com/

Image Credit:http://marketrealist.com/
4. HIGHLY DIVERSIFIED OFFERINGS: Salesforce is the innovator of the
SaaS approach in the enterprise space. Its proficiency in on-demand software
helps reduce the cost for customers as it provides a common networking, hardware and software platform. Customers can improve sales and enhance communication through various SaaS offerings of Salesforce namely Salesforce Chatter,
Sales Cloud, and Service Cloud applications.

10

Image Credit: http://www.thoughtexecution.com


Salesforce acquired Heroku in 2010 to provide its customers with PaaS (Platform
as a Service) to provide support for various programming languages. Users can
customize their applications with developer tools like TheAppExchange and Database.com. With diverse offerings and wide product portfolio, Salesforce is inventing the future while other competitive CRM software applications like the
Siebel are just trying to get into it.
5. Dawn of Salesforce1
Gartner has stated that by 2015, an overwhelming 60% of Internet users will have
a preference for mobile customer service applications, with various devices and
applications being available on a single platform.

11

To stay tuned with the increasing demand and growing trend, Salesforce launched
Salesforce1 in October 2013- an innovative CRM platform for software vendors,
developers, and customers for connecting applications and third-party services
such as Dropbox, Evernote and LinkedIn.Instant and customized Customer Service, On-Screen guided support and live video support are just some of the remarkable features of Salesforce1 which contribute to its dominance in the CRM
software space.
Salesforce1 has seen significant growth of active mobile application users which
is whopping 96% with 46% increase in the active users for customized mobile applications. Thus, Salesforce1 is successful in leveraging the growth in the Customer Relationship Management Software market by meeting the increasing demand mobile devices service providers.
What the future holds for Salesforce CRM Software?
With different Salesforce reviews on the web, it is palpable that though the cost
for salesforce CRM Software service is more, has the best user-friendly interface
when compared to other CRM softwares such as Siebel, SugarCRM. According to
IDC, the overall Marketing Automation market is poised to touch $5.5 billion in
2016 from $3.7 billion in 2011which presents exceptional growth projections for
Salesforce CRM in the marketing category.
Salesforce is on the brink to provide an array of diversified cloud applications and
services to meet the unquenchable demand for cloud computing. Salesforce Customer Relationship Management software is all set to grow exponentially in the
CRM software market.

What is App in Sales force?


An app is a group of tabs that work as a unit to provide functionality. Users can
switch between apps using the Force.com app drop-down menu at the top-right
12

corner of every page.


You can customize existing apps to match the way you work, or build new apps by
grouping standard and custom tabs.
Navigation to create app in Sales force: Setup ->Build ->Create->App->
Click on new and create your application according to your requirements.
What is object in Sales force?
Objects are similar to data tables, column headings are similar to object fields,
rows are similar to object records.
Navigation to create object in sales force:Setup->Build->Create->Object->
Click on new object and create object according to your requirement.
Can you name some of the standard objects and define their purposes?
Accounts: are your organizations customers, competitors, and partners. Each
account stores information such as name, address, and phone numbers.
Contacts: are the people that your company will have or already has an on-going
relationship. A contact, which is an individual associated with an Account.
Cases: A customer issue such as a customers feedback, problem, or question.
Solutions: A detailed description of a customer issue and the resolution of that
issue.
The relationship between product and price book?
Many-to-many relationship as show below:

13

Differences between custom objects and standard objects?


Objects already created for you by Salesforce are called standard objects. Objects
you create in your organization are called custom objects.
What is the difference between public cloud and private cloud? Is
salesforce.com is a public cloud or private cloud?
Public Cloud: Could services are provided as a service over the Internet with
little or no control over the underlying technology infrastructure. More than one
tenant can use the same resources.
Private Cloud: This also offers activities and functions as a service but is
deployed over a company intranet or hosted datacenter. This is private product
for a company or organization offering advance security.
Salesforce.com: Is a public cloud as it is hosted on salesforce.com data centers
and data of more than one tenant resides on same servers.
Standard Objects:
http://www.salesforce.com/us/developer/docs/object_reference/index_Left.ht
m#CSHID=sforce_api_objects_crontrigger.htm|StartTopic=Content%2Fsforce
_api_objects_crontrigger.htm|SkinName=webhelp

What is Standard and Custom Fields in Salesforce?


Standard Fields

Standard
Fields
are
pre-defined
in
Salesforce
You cannot delete standard fields but you can remove non-required standard
fields
from
a
page
layout
Standard Field customizations include the ability to change standard field labels
and tabs
You can change the display labels of standard tabs, objects, fields, and other
related user interface labels so they better reflect your organizations
business requirements.
Renamed labels for example, Accounts changed to Companies
display on all user pages, in Outlook Edition, and in Offline Edition.
Its important to note that all pages in the Setup area use the default, original
labels.
14

Reports and views are not renamed based on the new label value.
Custom
Fields
Capture information unique to your business process by creating custom fields
with
custom
field.
Recycle
Bin
for
Deleted
Custom
Fields
Custom fields are deleted permanently after 15 days.
Is it possible to change the existing data types of custom fields, if Yes
please explain?
Yes. Its possible but Changing the data type of an existing custom field can cause
data loss in the following situations:
Changing to or from type Date or Date/Time
Changing to Number from any other type
Changing to Percent from any other type
Changing to Currency from any other type
Changing from Checkbox to any other type
Changing from Picklist (Multi-Select) to any other type
Changing to Picklist (Multi-Select) from any type except Picklist
Changing from Auto Number to any other type
Changing to Auto Number from any type except Text
Changing from Text Area (Long) to any type except Email, Phone, Text, Text
Area, or URL
What is a dependent picklist?
Dependent fields can help make your data more accurate and consistent by
applying
filters.
A dependent field works in conjunction with a controlling field to filter its values.
The value chosen in the controlling field affects the values available in the
dependent
field.
300 is the maximum number of values allowed in a controlling picklist
- A custom multi-select picklist cannot be the controlling field for a dependent
field
Field Type

Controlling
Field

Dependent
Field
15

Standard
Yes
Picklist
Custom Picklist Yes
Custom Multi- No
Select
Standard
Yes
Checkbox
Custom
Yes
Checkbox

No
Yes
Yes
No
No

What are the system fields, audit fields and Standard fields?
System Fields: They are read-only & system generated fields. They are:
Id - Globally unique string that identifies a record.
15 Characters size if you access it inside the salesforce application. For
example, you can see 15 characters ID in the URL when you view the record.
18 Characters size if you access it from outside the salesforce application.
For example, When you use dataloader, or retreive the record from
developer console, etc..
IsDeleted this field is TRUE when the record is deleted or FALSE when the
record is not deleted.
Deleted records, fields, objects can be undeleted within 15 days of time.
Standard objects or Standard fields can NOT be deleted. Only custom fields of
standard object or custom objects can be deleted.
Audit Fields:
CreatedById- ID of the User who created this record.
CreatedDate- Date and time when this record was created. C
LastModifiedById- ID of the User who last updated this record.
LastModifiedDate- Date and time when this record was last modified by a user.
SystemModstamp - Date and time when this record was last modified by a
user or by an
automated process (such as a trigger).
Standard Fields:
ID
Name The field that is created while creating the object. It can be a Text or
16

Auto Number Data type


Owner Who created an object
CreatedById- ID of the User who created this record.
CreatedDate- Date and time when this record was created. C
LastModifiedById- ID of the User who last updated this record.
LastModifiedDate- Date and time when this record was last modified by a user.
SystemModstamp - Date and time when this record was last modified by a
user or by an
What is schema builder? Can we create objects & relationships using
schema builder?
Schema Builder provides a dynamic environment to add new custom objects,
custom
fields, and relationships to your schema. This eliminates the need to click from
page to
page to find the details of a master-detail relationship or to add a new custom field
to an
object in your schema. For example, if youre using Schema Builder to view the
details of
your schema, you can add a new custom object without leaving Schema Builder.
The draganddrop interface lets you easily add a custom object or new field, and saves the layout
of
your schema any time you move an object.
Schema Builder provides details such as the field values, required fields, and how
objects
are related by displaying lookup and master-detail relationships. You can view the
details
for both standard and custom objects in Schema Builder.
Schema Builder is enabled by default and lets you add the following to
your schema:
Custom objects
Lookup relationships
Master-detail relationships
Formulas/Rollup Summary Feilds.

17

What do you mean by Hierarchical Relationship and explain?


Hierarchical Relationship allows users to click a lookup icon and select another
user from a popup list.
Its exactly like a Lookup relationship, except the only things that are "special"
about
this type of relationship are:
It's only available on the User object where Lookup or Master/Detail are not.
It can only look up to the User object.
Type of relationship are easy ways to get:
- a user's complete upstream hierarchy (List)
- a user's complete downstream hierarchy (tree structure and/or Set)
- Determine if a user is in another user's upstream and distance
- Determine if a user is in another user's downstream and distance
Explain the relationships between two objects?
Master-Detail (one parent many children) A parent-child relationship
in which the master
object controls certain behaviors of the detail object:
Cascade record deletion- When a record of the master object is deleted, its
related detail records are also deleted.
Cascade record level secutiry - The Owner field on the detail object is not
available and it is automatically set to the owner of its associated master record.
18

So, the detail object cannot have sharing rules, manual sharing, or queues, as
these require the Owner field.
- Roll-Up Summary field are available for parent object only.
- Standard Object cannot be detail object. You can define master-detail
relationships between custom objects or between a custom object and a standard
object. However, the standard object cannot be child object.
Look up Relationship (one parent many children) :
-Relationship is optional. Child record can be stored without parent record.
- No impact on security. Child record have owner so they can have their own
sharing rules, manual sharing, queues.
Roll-Up Summary fields are not available for lookup relationship.
How many master-detail and lookup relationships we can have on one object?
we can create 2 Master Details and 25 lookups on one object.
Junction Object [Many to Many relationships]: Sometimes we may need
many-to-many relationships, and we can achieve that by having two one to many
relationships. For example one man can go to more than one shop and one Mall
can have more than one shop. Now one to many from man to Shop and another
one to many from mall to shop. So, the shop is junction object.

Difference between Sandbox and developer edition in Salesforce:


A test environment for salesforce.com is crucial to change control. Salesforce.com
provides the tools needed to test anything in a test environment before you
implement it in your live instance. You can either test in a Sandbox environment
or in a Developer environment. What is the difference? I will share what I know
Sandbox
The salesforce.com Sandbox environment is an exact copy of your salesforce.com
instance. You can copy your live instance to a sandbox environment (but you have
to perform manually from sandbox to developer edition) where you can test any
changes, implementations, AppExchange apps or updates. It can also be your
19

hands-on training environment without risking your live data.


You can either copy your configuration and data into a sandbox environment or
just the configuration. It acts exactly like your live instance, but be careful if you
have workflow rules or automations because they will work in the sandbox as well.
I know that this sounds wonderful and if you dont have it, you are dying to know
how to get it. The problem is the cost. If you are on Unlimited Edition, then cost
is not a problem because it comes included. But for Enterprise, Professional or
Group Editions, you have to pay and the price is hefty; anywhere between 25k50k per year. For a lot of companies, that is more than they are paying for their
live salesforce.com instance. So how do you test salesforce.com without Sandbox?
It is always suggested to develop application in sandbox instance then go for LIVE.
Developer Edition
Developer Edition was an edition created for development of integrations and
apps, specifically for the AppExchange. It is also a great tool for testing/training
in salesforce.com. What makes this a great tool is the fact that it is free. Anyone
can get a Developer Edition of salesforce.com. It is a standard Enterprise Edition
with very limited storage space. You cannot copy your configuration or data onto
the Developer Edition, but you can customize it to match your instances look and
feel. Once it is customized, you can use it for training, testing or anything else you
want. It takes a little bit of work, but you can make it act and feel just like your live
instance. The work is well worth it for the free price.
To get a copy of Developer Edition for yourself or your company go here. Play
around with it. Get apps from the AppExchange. Do anything and everything that
you have been scared to do your live system. If you come up with a clever way of
using the system, post it on AppExchange and share your knowledge.
What are the types of email templates available in salesforce.com?
Text
HTML with Letter Head
Custom HTML
Visual force

What is the difference between External ID and Unique ID?

20

External ID
This is a field that usually references an ID from another (external) system. For
instance, if the customer has an Oracle Financials system that they will be linking
with salesforce.com, it may be easier for them to be able to refer to the Oracle ID
of account records from within salesforce. So they would create an external ID in
salesforce.com and they would load the Oracle ID into that field for each account.
They can then refer to that ID field, rather than the salesforce.com id.
Additionally, if you have an external ID field, the field becomes searchable in the
sidebar search. You also can use the upsert API call with the extenal ID to refer to
records.
You can have multiple records with the same external ID (though it is not
reccomended, as it will defeat the purpose of the external id) .
External Id available for Text, Number and Email field types.
External Id is used in upsert operations.
If external id is absenor not matched then insert happens.
If external id matched once then record will be updated.
If external id is matched multiple times then error occurs.
Unique ID field
This is a setting for the field that will prevent you from using the same value in
multiple records for the unique field. So if I create a 5 character text field and
make it unique, and I create a record with the value 12345 i will not be able to
create another record with that same value in the unique field. If i try to do so, I
will get an error saying that the value is already in use.
Often, External Ids are set with the unique property so that the IDs will be unique
to each record.

21

What is the custom settings ?


Custom settings are similar to custom objects and enable application developers
to create custom sets of data, as well as create and associate custom data for an
organization, profile, or specific user. All custom settings data is exposed in the
application cache, which enables efficient access without the cost of repeated
queries to the database. This data can then be used by formula fields, validation
rules, Apex, and the Web services API.

Types of the custom settings?


List Custom Settings
A type of custom setting that provides a reusable set of static data that can be
accessed across your organization. If you use a particular set of data frequently
within your application, putting that data in a list custom setting streamlines
access to it. Data in list settings does not vary with profile or user, but is available
organization-wide. Examples of list data include two-letter state abbreviations,
international dialing prefixes, and catalog numbers for products. Because the data
is cached, access is low-cost and efficient: you dont have to use SOQL queries that
count against your governor limits.
Hierarchy Custom Settings
A type of custom setting that uses a built-in hierarchical logic that lets you
personalize settings for specific profiles or users. The hierarchy logic checks the
22

organization, profile, and user settings for the current user and returns the most
specific, or lowest, value. In the hierarchy, settings for an organization are
overridden by profile settings, which, in turn, are overridden by user settings.

List things that can be customized on page layouts?


We can customize different things on page layout like, Fields, Buttons, Custom
Links and Related Lists. We can also create sections.
What is workflow? Have you worked on workflow rules?
Yes.. we have created workflow rules for sending patient queries to the doctor. We
write workflow rules when we want to automate functionality.
Workflow rules can be written based on two conditions:
Criteria based For example as soon as we receive a call from patient.
Time Based Sending an email to the patient their appointment. For
example, your appointment is at 2:30 PM tomorrow.
Workflow automates the following actions:
Tasks I worked in Doctor management Application before I worked
on patient service Application where we need to setup tasks to remind
doctors on operations date, surgeries date, etc..
Email AlertsSend an email to the doctor if there is any query from the
patient or send an email to the patient reminding their appointment.
Field Updates The status filed will be updated to Contacted after
successful contact. The Status will be updated to Pending if the contact
was not successful.
Outbound MessagesSend messages to third part applications.
Have you worked on reports and Dashboards? What is report? What
is dashboard?
Yes, I was involved in creating reports.
We have created reports to list of all doctors working in a specific branch
using Tabular Report.
Doctor ID, Doctor Name, Phone Number, Email,
Total number of doctors: 120
We have created report to list of all doctors based on their specialization
using Summary Reports
Specialization(Women's Health ):
23

Doctor ID, Doctor Name, Phone Number, Email,


Total number of doctors: 20
We have created report to list doctors based on their specialization and their
experience using Matrix Reports
Specialization (Women's Health)
Experience > 10 Years:
Doctor ID, Doctor Name, Phone Number, Email,
Total number of doctors: 7
What is difference in ISNULL and ISBLANK?
ISNULL:
Determines if an expression is null (blank) and returns TRUE if it is. If it
contains a value, this function returns FALSE.
Text fields are never null, so using this function with a text field always
returns false. For example, the formula field IF(ISNULL(new__c) 1, 0) is
always zero regardless of the value in the New field. For text fields, use the
ISBLANK function instead.
Multi-select picklist fields are never null in s-controls, buttons, and email
templates, so using this function with a multi-select picklist field in those
contexts always returns false.
Empty date and date/time fields always return true when referenced in
ISNULL functions.
Choose Treat blank fields as blanks for your formula when referencing a
number, percent, or currency field in an ISNULL function. Choosing Treat
blank fields as zeroes gives blank fields the value of zero so none of them will
be null.
Merge fields can be handled as blanks, which can affect the results of
components like s-controls because they can call this function.
When using a validation rule to ensure that a number field contains a
specific value, use the ISNULL function to include fields that do not contain
any value. For example, to validate that a custom field contains a value of 1,
use the following validation rule to display an error if the field is blank or
any other number: OR(ISNULL(field__c), field__c<>1)
ISBLANK:
Determines if an expression has a value and returns TRUE if it does not. If
it contains a value, this function returns FALSE.
Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the
same functionality as ISNULL, but also supports text fields. Salesforce.com
will continue to support ISNULL, so you do not need to change any existing
formulas.

24

A field is not empty if it contains a character, blank space, or zero. For


example, a field that contains a space inserted with the spacebar is not
empty.
Use the BLANKVALUE function to return a specified string if the field does
not have a value; use the ISBLANK function if you only want to check if the
field has a value.

If you use this function with a numeric field, the function only returns TRUE
if the field has no value and is not configured to treat blank fields as zeroes.
How many ways we can made field is required?
1. While creation of field
2. Validation rules
3. Page Layout level
What is the maximum size of the PDF generated on visualforce
attribute renderAs?
15MB
What is a profile?
A profile contains user permissions and access settings that control what users
can do within their organization.
Profiles control:
Which standard and custom apps users can view
Which tabs users can view
Which record types are available to users
Which page layouts users see
Object permissions that allow users to create, read, edit, and delete records
Which fields within objects users can view and edit
Permissions that allow users to manage the system and apps within it
Which Apex classes and Visualforce pages users can access
Which desktop clients users can access
The hours during which and IP addresses from which users can log inidentity
provider)
What is Permission Set?
A permission set is a collection of settings and permissions that give users access
to various tools and functions. The permission sets extend users functional access
without changing their profiles.
For example, to give users access to a custom object, create a permission set,
25

enable the required permissions for the object, and assign the permission set to
the users. Users can have only one profile, they can have multiple permission sets.
What is OWD?
OWD(organization wide defaults) provide an access to all users in that
organization. There are 4 types of OWDs:
private no once can access it except the owner.
Public Read Only Every can read the record based on their profile permissions
for that object.
Public Read/Write - Every can read or edit the record based on their profile
permissions for that object.
Public Read/Write/Transfer - Every can read or edit or transfer the record based
on their profile permissions for that object.
What is most restricted level of access?
Profile is most important.
How do you implement record level security? Or Types of Security?
There are different ways to control the record level access:
profile, permission sets, OWD, Role Hierarchy, Sharing Rules, Manual Sharing,
Apex Sharing (writing apex method to control) the records.
What is Role?
We use Roles to provide vertical access. For example, if A is in higher position
than B then if we want to give additional permissions on B's records to A then we
use Roles. Depending on your sharing settings, roles can control the level of
visibility that users have into your organizations data.
Can we create a user without profile?
No, we can not create user without profile. Every user in salesforce must have
profile.
If you hide a tab in profile than the user can see the records?
No, they can see the records in UI. But if they have permission on that object then
they can query records from the database using SoQL or SOSL or they can use
tools like force.com explorer, etc..
The differences between public group, private group and Queue?
Groups are sets of users. They can contain individual users, other groups, the
users in a particular role or territory, or the users in a particular role or territory
plus all of the users below that role or territory in the hierarchy.
26

Public Groups: Only administrators can create and edit public groups
Private Groups: Any user can create and edit their own personal groups.
Queues: Queues help your teams manage leads, cases, service contracts, and
custom objects. Once records are placed in a queue manually or through an
automatic case or lead assignment rule, records remain there until they're
assigned to a user or taken by one of the queue members. Any queue member or
users above them in the role hierarchy can take ownership of records in a queue.
Can we create a custom profile?
Yes, we can create a custom profile by using the exiting profile.
How many ways do you share the records?
Salesforce has the following types of sharing:
Record Ownership: Owner will have full access by default on all records
to view, edit, transfer, share, and delete the record.
Role Hierarchy: We use Roles to provide vertical access. For example, if A
is in higher position than B then if we want to give additional permissions on
B's records to A then we use Roles. Depending on your sharing settings, roles
can control the level of visibility that users have into your organizations data.
Sharing Rules: Sharing rules are used by administrators to automatically
grant users within a given group or role access to records owned by a specific
group of users. Sharing rules can be based on record ownership or other
criteria.
Manual Sharing - Users can manually share records access with other users
including accounts, contacts, and leads. In some cases, sharing one record
includes access to all its associated records. This method of granting access is also
known as a manual share.
Apex Managed Sharing: Apex managed sharing provides developers with the
ability to support an applications particular sharing requirements
programmatically through Apex or the SOAP API. This type of sharing is similar
to Force.com managed sharing. Only users with Modify All Data permission can
add or change Apex managed sharing on a record.
What is the use of Transfer Record in profile?
If user have only Read access on particular record but he wants to change
the owner name of that record, then in profile level Transfer Record enables he
can able to change the owner.
What is Field dependency?
27

According to the field selection on one field filter the pick list values on
other field.
Is check box performs like controlling field?
Yes possible. Controlling field should be Check box or pick list.
What are formula and Rollup Summary fields and Difference between
them? When should Rollup- Summary field enable?
Formula: A read-only field that derives its value from a formula expression that
we define. The formula field is updated when any of the source fields change.
Rollup Summary: A read-only field that displays the sum, minimum, or
maximum value of a field in a related list or the record count of all records listed
in a related list.
Difference is below:
Formula fields calculate values using fields within single record, roll-up summary
fields calculate values from a set of related records.
When we give the master-detail relationship it gets enable to the master object
What are the Record Types?
Record Types are restrict the pick list values and assign to the different
page layouts for different Record Types.
What is Audit Trail?
Audit Trail provides the information or track all the recent setup changes that an
administrator done to the organization.
This can store the last 6 months data.
What are the Report Types?
4 Types of report in Salesforce
Tabular Reports: We can only displays the grand total in the table form.
Summary Reports: It is a detail form of report in which the grouping done
based on Columns.
Matrix Reports: It is a detail form of report in which the grouping done based
on both Rows and Columns.
28

Joined Reports: We can join the two or more reports in the single report
displayed in the form of blocks.
What is Dashboard?
Dashboard is a pictorial representation of report. We can add up to 20 reports in
single dashboard.
Pros of Private Cloud
Security: The security risks associated with the private cloud tend to be

less prominent than those of the public cloud. The location of the data is
available to the service owner unlike with the public cloud.
Costs: The initial costs of the private cloud tend to be higher than the public
cloud but decline as the time of usage increases.
Data Storage: Larger amounts of data can be stored in the private cloud
for a lower cost.
Pros of Public Cloud
Costs: The initial costs of the public cloud are lower but tend to go up over

time.
Data Storage: Many different types of data can be stored in the public
cloud however large amounts stored for long periods tend to get pricey.
Accessibility: The public cloud can be accessed from a number of location
and a number of ways unlike the private which can only be reached from
one source.
Availability: The public cloud has so far proven to be more reliable and
available thus drawing many users.

1. The difference between Lead and the opportunity?


Leads - are people who attend our campaigns to know more about our products.
If you have never contacted your contact, its a lead.
opportunities - are people who shown interest in our products.
The opportunity is a deal that you have the possibility to close!
2. Through Sales force Import wizard how many records we can
import into salesforce Objects and the wizard will support for which
29

Objects?
Using Import wizard, we can upload up to 50,000 records.Only Accounts &
Contacts, Leads and Solutions and custom objects data can be imported. If we
want to import other objects like Opportunities and other objects data, then we
need to go for Apex Data Loader.

SDLC Methodologies (Software Development Life Cycle):


There are 3 most commonly used SDLC methodologies:
1) Waterfall Model design
Waterfall approach is also called sequential method as In Waterfall model, the
outcome of one phase acts as the input for the next phase sequentially.

30

Advantages

Disadvantages
No working software is produced until
late during the life cycle.

Simple and easy to understand and


Not a good model for complex and objectuse
oriented projects.
Phases are processed and
Poor model for long and ongoing
completed one at a time.
projects.
Works well for smaller
projects where requirements It is difficult to measure progress within
stages.
are very well understood.
Clearly defined stages.
Well understood milestones.

Cannot
accommodate
requirements.

changing

Easy to arrange tasks.

No working software is produced until


late in the life cycle.

Process and results are well


documented.

Adjusting scope during the life cycle


can end a project.

Agile SDLC: It is also called incremental model where as and when they find
the new requirements, they implement, test and create unit test cases for
31

regression, then they find the gap, follow the same process again. Most
complicated and very reliable methodology.

11. What the Salesforce System Fields?


The following fields are read-only fields found on most objects. These fields are
automatically updated during API operations.
System Fields:
Id - Globally unique string that identifies a record. For information on IDs, see
ID Field
Type. Because this field exists in every object, it is not listed in the field table for
each
32

object. Id fields have Defaulted on create and Filter access.


IsDeleted - Indicates whether the record has been moved to the Recycle Bin (true)
or not
(false). Because this field does not appear in all objects, it is listed in the field table
for each
object.
Audit Fields
CreatedById- ID of the User who created this record. CreatedById fields have
Defaulted on
create and Filter access.
CreatedDate- Date and time when this record was created. CreatedDate fields
have
Defaulted on create and Filter access.
LastModifiedById- ID of the User who last updated this record.
LastModifiedById fields
have Defaulted on create and Filter access.
LastModifiedDate- Date and time when this record was last modified by a user.
LastModifiedDate fields have Defaulted on create and Filter access.
SystemModstamp - Date and time when this record was last modified by a user
or by an
automated process (such as a trigger). SystemModstamp fields have Defaulted on
create
and Filter access.
12. What are the differences between System Mod Stamp and Last
Modified Date?
System Mod Stamp and Last Modified Date are approximately same everytime.
You will find same value for both the fields, however, there are few examples when
they might differ. Example :
If any organization's business requirement is to move all the data/records which
already exist in one org, to another, they will require to keep the created and last
modified date same as when the record was actually created or modified in the
original org and not when the data was moved in the new org.
In this case, Salesforce provides an option to modify the Last Modified date and
keep it in sync with your original records creation or modified date.
System Mod Stamp in this case will change to the new date when the data/record
was uploaded in new org, however, Last Modified date can manually be changed
to the original date when the records were modified in old org.

33

13. What are the differences between soft delete & Hard delete in
salesforce?
Hard Delete Vs Soft Delete:
Deleted Records:
The Recycle Bin link in the sidebar lets you view and restore recently deleted
records for 15
days before they are permanently deleted. If your organization reaches its
Recycle Bin limit,
Salesforce automatically removes the oldest records if they have been in the
Recycle Bin for at
least two hours. Your organization can have up to 5,000 records per license in
the Recycle Bin
at any one time. For example, if your organization has five user licenses, 25,000
records can
be stored in the Recycle Bin.
Deleted Fields:
Deleted custom fields and their data are stored until your organization
permanently deletes
them or 15 days has elapsed, whichever happens first. Until that time, you can
restore the field
and its data. However, the field still counts against the maximum number of
custom fields
allowed in your organization.
Standard fields can not be deleted ONLY customer fields of standard
or custom object
can be deleted.
Deleted Objects:
When you delete a custom object, Salesforce does not add it to the Recycle Bin.
Instead,
deleted objects appear in the Deleted Objects list for 15 days. During this time, the
object
and its data are soft deleted, meaning you can restore or permanently erase (hard
delete)
the object and its data. After 15 days, the object and its data are automatically
hard
deleted.

34

Q2) Data Migration Tools:


Data Import Wizard The Data Import Wizard provides a unified interface
that lets you import data for a number of standard Salesforce objects, including
accounts, contacts, leads, and solutions. The wizard also lets you import
data for custom objects. Using this tool you can import Up to 50,000.
Data Export There is no limit in export. An in-browser wizard that exports
data in .zip files that are up to 128 MB each on a monthly or weekly basis.
Data Loader Using this tool you can import between 5,000 and 5 million.
Q3) What are the issues that encounter when load the data?
1) Data can not be loaded if there is no correct mapping. For example if inserting
an account with account name ( Required field).
2) Failure when try to update a record without ID field. To update a record we
must have id field.
3) Limitations For example if we use import wizard to import more than 50,000
at once.
Q4) What is the difference between Export and Export All?
Export Returns all active records.
Export All Returns all active records and also the records in recycle bin
(deleted records).
Q5) What is an external ID and when to use it?
An external ID contains unique record identifiers from a system outside of
Salesforce. We use them when you import the records. When you select this
option, the import wizard will detect existing records in Salesforce that have the
same external ID. We can have upto 7 external ids for one object.

35

Q6) What is upsert operation?


Upsert It inserts if the record does not exist or update if the record exists. We
need to have ID values existing records to update.
Q7) How many external Ids can we have for an object?
We can have up to 7 external ids for an object. The field type must be a text,
number, or email field. An external ID contains record IDs from a system outside
of Salesforce.
Q8) Can you import audit fields during the data migration?
If you import data into Salesforce and need to set the value for an audit field. The
36

only audit field you cannot set a value for is systemModstamp.


Q9) How do we choose the migration tool to use?
Based on the number of records to be imported or exported.
Data Import Wizard Use this tool you can import Up to 50,000.
Data Export There is no limit in export.
Data Loader Using this tool you can import between 5,000 and 5 million.
We also use below the tools
Excel Connector
Force.Com Explorer
Merge Tool for Account and Contact
Third Party Tools
Q12) What is record id?
It is unique id given by salesforce for each and every record.
Q13) What is record type? And record type id?
Record Types are used to create different business processes. For example, When
you create a salesforce application for automobile company and if the automobile
company produces two-wheeler and 4 wheelers then we do not need to have same
application for both types. We can less fields for 2 wheeler and more fields for 4
wheeler from pickup list.
Record type id Is the ID given by salesforce for record type. We use getRecordId()
method to get record type ids.
Q14) What are the different ways to get record id?
1) We get from URL in UI by selecting the record in UI.
2) Querying database using select statement.
3) Using Force.com IDE.

Security Questions:
a record.
Object Relationships in SalesForce

37

Use relationships to associate an object with other objects in Salesforce. You can
define different types of relationships by creating custom relationship fields on an
object.
There four different relationships can be built in Force.com Platform.
Look up (Parent and Child) Two Different Objects
Self Lookup (Same Object) Self Relationship is a lookup relationship on the
same object
Master Detail - This type of relationship closely links objects together such that
the master record controls certain behaviors of the detail
Many To Many - many-to-many relationships between any two objects
SalesForce has two data types to create relationships. Look up and Master Detail
Look up Relationship
Loosely coupled
Child field may be optional
No cascade Delete
Independent ownership and sharing
Maximum 25 lookup relationships per child object
Master Detail Relationships
Child field value is always required
Cascade Delete
Inherited ownership and sharing
Maximum 2 master relationships per detail object
Many to Many Relationship
A many-to-many relationship allows each record of one object to be linked
to multiple records from another object and vice versa.
Use Junction Object to connect the two objects
A Junction Object is a custom object with two Master Detail relationships
Look up
Parent is not required field
No impact on security and
sharing
No cascade delete

Master Detail
Parent is required field
Inherits parent security
and sharing
Cascade Delete

38

25
relationships
possible

are Only 2 per object

A profile contains user permissions and access settings that control what users
can do within their organization
Which standard and custom apps users can view
Which tabs users can view
Which record types are available to users
Which page layouts users see
Object permissions that allow users to create, read, edit, and delete records
(CRUD)
Which fields within objects users can view and edit
Permissions that allow users to manage the system and apps within it
Which Apex classes and Visualforce pages users can access
Which desktop clients users can access
The hours during which and IP addresses from which users can log in
Which service providers users can access (if Salesforce is enabled as an identity
provider)
In Contact Manager, Group, and Professional Edition organizations, you can
assign standard profiles to your users,
but you can't view or edit the standard profiles or create custom profiles. In
Enterprise, Unlimited, and Developer
Edition organizations, you can use standard profiles, or create, edit, and delete
custom profiles. For standard profiles,
only certain settings can be changed.
Each standard or custom profile belongs to exactly one user license type.
What is a Permission Set?
A permission set is a collection of settings and permissions that give users access
to various tools and functions.
The settings and permissions in permission sets are also found in profiles, but
permission sets extend users' functional access without changing their profiles.
For example, to give users access to a custom object, create a permission set,
enable the required permissions for the object, and assign the permission set to
the users. You never have to change profiles, or create a profile for a single use
case.
39

While users can have only one profile, they can have multiple permission sets.
Can you assign a Permission Set to Public Group?
Record Level Security (Sharing)
Record-Level Security (Sharing)
Record-level security lets you give users access to some object records, but not
others. Every record is owned by a user or a queue. The owner has full access to
the record.
Organization Wide Defaults, Role Hierarchy, Sharing Rules, Manual
sharing Rules, Apex Managed Sharing Rules are different settings in SalesForce
to share the record with other users.
Organization Wide Defaults settingsThe first step in record-level security is to
determine the
organization-wide sharing settings for each object. Organization-wide sharing
settings specify the
default level of access users have to each others records.
Private
Public Read Only
Public Read Write
You use organization-wide sharing settings to lock down your data to the most
restrictive level, and then use the other record-level security and sharing tools to
selectively give access to other users. For example, lets say users have object-level
permissions to read and edit opportunities, and the organization-wide sharing
setting is Read-Only. By default, those users can read all opportunity records, but
cant edit any unless they own the record or are granted additional permissions.
Role hierarchyOnce youve specified organization-wide sharing settings, the
first way you can give wider access to records is with a role hierarchy. Similar to
an organization chart, a role hierarchy represents a level of data access that a user
or group of users needs. The role hierarchy ensures that users higher in the
hierarchy always have access to the same data as people lower in their hierarchy,
regardless of the organization-wide default settings. Role hierarchies dont have
to match your
organization chart exactly. Instead, each role in the hierarchy should represent a
level of data access that a user or group of users needs.
You can also use a territory hierarchy to share access to records. A territory
hierarchy grants users access to records based on criteria such as zip code,
industry, revenue, or a custom field that is relevant to your business. For example,
you could create a territory hierarchy in which a user with the North America
role has access to different data than users with the Canada and United States
roles.
Note
Although its easy to confuse permission sets and profiles with roles, they control
40

two very different things. Permission sets and profiles control a users object and
field access permissions. Roles primarily control a users record-level access
through role hierarchy and sharing rules.
Sharing rulesSharing rules let you make automatic exceptions to organizationwide sharing
settings for particular sets of users, to give them access to records they dont own
or cant normally see. Sharing rules, like role hierarchies, are only used to give
additional users access to recordsthey cant be stricter than your organizationwide default settings.
Manual sharingSometimes its impossible to define a consistent group of users
who need access to a particular set of records. In those situations, record owners
can use manual sharing to give read and edit permissions to users who would not
have access to the record any other way. Although manual sharing isnt automated
like organization-wide sharing settings, role hierarchies, or sharing rules, it gives
record owners the flexibility to share particular records with users that need to
see them.
Apex managed sharingIf sharing rules and manual sharing dont give you the
control you need, you can use Apex managed sharing. Apex managed sharing
allows developers to programmatically share custom objects. When you use Apex
managed sharing to share a custom object, only users with the Modify All Data
permission can add or change the sharing on the custom object's record, and the
sharing access is maintained across record owner changes.
Triggers and Order of Execution
When you save a record with an insert, update, or upsert statement, Salesforce
performs the following events in order.
Note
Before Salesforce executes these events on the server, the browser runs JavaScript
validation if the record contains any dependent picklist fields. The validation
limits each dependent picklist field to its available values. No other validation
occurs on the client side.
On the server, Salesforce:
1. Loads the original record from the database or initializes the record for an
upsert statement.
2. Loads the new record field values from the request and overwrites the old values.
If the request came from a standard UI edit page, Salesforce runs system
validation to check the record for:
Compliance with layout-specific rules
Required values at the layout level and field-definition level
Valid field formats
Maximum field length
Salesforce doesn't perform system validation in this step when the request comes
41

from other sources, such


as an Apex application or a SOAP API call.
1. Executes all before triggers.
2. Runs most system validation steps again, such as verifying that all required
fields have a nonnull value, and runs any user-defined validation rules. The only
system validation that Salesforce doesn't run a second time (when the request
comes from a standard UI edit page) is the enforcement of layoutspecific rules.
3. Saves the record to the database, but doesn't commit yet.
4. Executes all after triggers.
5. Executes assignment rules.
6. Executes auto-response rules.
7. Executes workflow rules.
8. If there are workflow field updates, updates the record again.
9. If the record was updated with workflow field updates, fires before and after
triggers one more time (and only one more time), in addition to standard
validations. Custom validation rules are not run again.
1. Executes escalation rules.
2. If the record contains a roll-up summary field or is part of a cross-object
workflow, performs
calculations and updates the roll-up summary field in the parent record. Parent
record goes through save procedure.
3. If the parent record is updated, and a grand-parent record contains a roll-up
summary field or is part of a cross-object workflow, performs calculations and
updates the roll-up summary field in the parent record.
Grand-parent record goes through save procedure.
4. Executes Criteria Based Sharing evaluation.
5. Commits all DML operations to the database.
6. Executes post-commit logic, such as sending email.
How to Write a trigger that automatically create a contact when
account is created?
trigger AccountTrigger on Account (after insert) {
List<Contact> contactList = new List<Contact>();
for(Account acc : trigger.new) {
Contact con = new Contact();
con.AccountId = acc.Id;
contactList.add(con);
}
if(!contactList.isEmpty()) {
insert contactList;
42

}
}

Can we have custom controller extions without custom controller?


YOU CAN NOT.

Custom Controller order test:


Controller-1 as a first argument for extensions:

43

Controller-3 as first argument in extensions:

Scenarios:
1)

How do you create one to one relationship using lookup relationship?


44

trigger One_to_OneRelationshipTrigger on Student__c (before insert) {


list<student__C> ls=[select name, Course__c from student__C];
for(student__C s:ls)
if(s.course__c <> null)
trigger.new[0].adderror('This is one to one relation and I can not add this
record for this parent' );
}
Result:

2) Why do need customer controllers when we have standard


controllers?
We use them when we need information from multiple objects or to write our
own custom logic?
Example:
VFP for CustomController:
<apex:page
extensions="CustomControllerExt1">

controller="CustomerController"
45

<apex:pageBlock title="{!CompanyName}">
<apex:pageBlockSection columns="1">
<apex:pageBlockTable value="{!allaccounts}" var="a">
<apex:column headerValue="Account Name">
<apex:outputText value="{!a.name}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection columns="2">
<apex:pageBlockTable value="{!allContacts}" var="a">
<apex:column headerValue="Contact Name">
<apex:outputText value="{!a.name}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection columns="3">
<apex:pageBlockTable value="{!allEmployees}" var="a">
<apex:column headerValue="Employee Name">
<apex:outputText value="{!a.name}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Custom Controller:
public class CustomerController {
public list<account> getallaccounts()
{
return ( [select name from account]);
}
public list<contact> getallContacts()
{
return ( [select name from contact]);
}
public list<Employee__c> getallEmployees()
{
return ( [select name from Employee__c]);
}
}

46

3) Write a test class to test more than one piece of apex code (apex
code could be a trigger or could be a class)?
Can we write more than one test method in one test class? Can we
write trigger test method, schedulable Class Test methods in one Test
Class?
Trigger 1:
trigger TestRejectDuplicateTrigger on Account (before insert,before update) {
list<account> la=[select name from account];
account a=trigger.new[0];
for(account ac:la)
if(ac.name == a.Name)
a.addError('Found duplicate, Can not Insert, can not update');
}
Trigger 2:
trigger TestCodeCoverage on Book__c (before insert,before update)
{
if((trigger.isbefore) && (trigger.isinsert))
system.debug('This trigger is fired due to insert');
if((trigger.isbefore) && (trigger.isupdate))
system.debug('This trigger is fired due to update');
list<Book__c> lb=[select name from Book__c];
book__C iORu=trigger.new[0];
for(book__c b: lb)
if (b.name == iORu.name)
iORu.addError('Found duplicate, Can not Insert & update');
}
Schedulable Class 1:
global class ScheduleEmailTest implements schedulable
{
global void execute(schedulablecontext sc)
{
Messaging.SingleEmailMessage mail=new Messaging.SingleEmailMessage();
mail.setToAddresses(new string[]{'ChinthamRR@gmail.com'});
mail.setReplyTo('info@rnritsolutions.com');
mail.setSenderDisplayName('Raveendra');
47

mail.setSubject('All Account Details');


list<account> accs=[select name from account];
integer i=1;
string s=i+' :';
for(account a:accs)
{
i+=1;
s=s+' ' + a.name + ' ' + i + ':';
}
mail.setplaintextbody(s);
messaging.sendEmail(new messaging.SingleEmailMessage[]{mail});
}
}
One Test Class with more than on testMethods:
@isTest(seealldata=true)
public class TestScheduleEmailClass {
static testmethod void emailtest()
{
Messaging.SingleEmailMessage mail=new Messaging.SingleEmailMessage();
mail.setToAddresses(new string[]{'ChinthamRR@gmail.com'});
mail.setReplyTo('info@rnritsolutions.com');
mail.setSenderDisplayName('Raveendra');
mail.setSubject('All Account Details');
list<account> accs=[select name from account];
integer i=1;
string s=i+' :';
for(account a:accs)
{
i+=1;
s=s+' ' + a.name + ' ' + i + ':';
}
mail.setplaintextbody(s);
messaging.sendEmail(new messaging.SingleEmailMessage[]{mail});
ScheduleEmailTest s1=new ScheduleEmailTest();
system.schedule('Email All account Details', '0 0 0 15 7 ? 2022', s1);
}
static testMethod void triggerRejDupstest()
{
account a=new account(name='Bank Of America 99', numberofemployees=250);
database.saveresult sr=database.insert (a,false);
system.debug(sr.geterrors());
account a1=[select name from account where name like 'Bank%99' limit 1];
48

a1.name = a.name + '+';


database.saveresult sr1=database.update (a1,false);
system.debug(sr1.geterrors());
}
static testMethod void triggerTest()
{
Book__c b=new Book__C();
b.Name = 'Book inserted by Test Method';
b.Price__c = 20;
database.saveresult sr=database.insert(b,false);
system.debug(sr.geterrors());
Book__c b1=[select name, price__c from Book__c where name like '%Test%'
limit 1];
b1.Price__c = b1.Price__c * 0.2;
database.saveresult sr1=database.update(b1,false);
system.debug(sr1.geterrors());
}
}
4) Write trigger to reject duplications if more than one record
inserted at a time with dataloader or import wizard?
Update status and stage fields in job application object when the record is created
in offer
object.
Test Cases:
1) Create a record in offer object.
2) Verify if the record created in offer object?
3) Verify if below fields are set in job application object?
Status to 'Approved'
Stage to 'Offer Extended'
Object: Job Application
Job Description, Status, Stage
Object: Offer
Status (Accepted, Rejected, Pending)
trigger UpdateStatusAndStageFieldsInParent on Offer__c (after insert) {
list<Job_Application__c>
lj=new
list<Job_Application__c>();
49

List<offer__C>
lo
list<job_application__C>
listjobs=[select
id,
job_application__C];
for
(offer__c
for(job_application__C
if(o.Job_Application__c
==

=trigger.new;
name
from
o:lo)
j:listjobs)

j.id)
{
J.status__c='Approved';
J.stage__C='Completed';
lj.add(j);
}

update

lj;

How many controllers can be used in a visual force page?


we can use one controller and as many extension controllers.
What is difference between Action support and Action function?
Action function: Invoke the controller method from java script using AJAX and
we can use action function from different places on visual force page.
Action support: Invoke the controller method using AJAX when even occurs on
page like onMouseOver, onClick, ect and we can use action support for
particular single apex component.
How many ways we can call the Apex class?
1. Visual force page
2. Web Service

50

3. Triggers
4. Email services

Display related contacts for a given account using Visualforce Page?


<apex:page
<apex:form
<apex:pageBlock
<apex:pageBlockTable
<apex:column

standardController="Account"

>
>
>

value="{!account.contacts}"
var="c">
value="{!c.name}"/>

</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

51

1) Write a apex code to test if a given account exists using LIST and
SET?
public class TestCollectionDataTypes {
public void display()
{
list<account> la=[select name, numberofemployees, annualrevenue from
account];
set<account> sa= new set<account>();
for(account a:la)
sa.add(a);
account aa=[select name, numberofemployees, annualrevenue from account
where name like 'Edge%' ];
system.debug('Is Edge Communication exists in sa? ' + sa.contains(aa));
system.debug('All accounts in sa? ' + sa);
}
}

52

Cisco

Call

Center

App:

Cisco systems use salesforce as their ticketing system where they can store
information on all cases/resolutions. I was involved in creating triggers based on
the ticket severity (severity 1 cases should be resovled in 24 hours, sev 2 should
be
resolved
in
2
days,
sev
3
and
4
in
one
week)
I have created a trigger to notify support manager as soon as we receive a ticket
of sev 1 so that support manager will assign that ticket to SME of their team for
faster
resolution.
I was involved in creating workflow rules for even distribution of work load with
all engineers in queue. so that all engineers will enough workload.
Created a workflow to notify manager if there is no progress on any ticket after 14
days of the ticket creation so that this ticket will be assigned to some expirenced
engineer
for
faster
resolution.
Created a trigger to notify an support manager as soon as SYSTEM DOWN
condition ticket hits the pmr . SYSTEM DOWNs are very critical for production
servers
and
they
have
to
be
resolved
in
2
hours.
Created different kinds for reports for support manger to discuss on weekly calls:
Weekly
Reports:
1) Case number, Age of the Case, Severity of the Case, Assigned Engineer.
2) New case number, description, customer details, Time zone, Is Engineer
Assigned(Yes/No)
3) Closed Case Number, Description, age, closure procedure (did we resolve the
issue/customer
resolved
own
issue/did
we
provide
fix)?
NCI
Sales
App:
NCI use salesforce for their marketing, sales. For marketing, the store
information about their leads and opportunities and customers.
Leads - who have shown interest to know more about our products by visiting our
53

webinars,
campigns,
workshops,
direct
mails,
etc.
Opportuinites - Who have shown interest in our products but expecting some kind
of
offers/approvals,
I was involved in creating workflow rules to notify concerned marketing
sales/marketing team with all details on new lead or opportunity so that
sales/marketing
will
follow
up
with
leads/opportunities.
I was involved in writting triggers to make sure we have all the information
required to contact lead/opportunity for further follow up at the time record
creation.
I was involved in creating trigger to have all details including next communication
date, whom did we contact, complete description of our conversation, etc.. during
the
record
update.
I was invloved in creating REST webservices to receive complete information by
giving their phone number or email id. To create Webservices, the customer site
should be registered with salesforce and once registed then we can the
information
required
by
giving
the
id
of
the
record.
I was invloved in creating REST webservices to receive complete information on
shipping address, quantity of material to be shipped by giving the order number.O
I was also involved in creating various reports on orders, current stock, ordered
stock, etc..
Please
let
me
know
if
you
have
any
questions?

Week-1

Do you know how to call Java Script from Visualforce Pages?


Yes.. I have used some of the javascripts in visual forces to display date or simple
programs like increasing numbers etc..
In visual force pages, we use<script> keyword to start javascript and </script>
(backslash script) to end the script.
Example:
<apex:page >

54

<script>
function DisplayDate()
{
document.write(Date());
}
</script>
<apex:form>
<apex:commandButton value="Display Date!!" onclick="DisplayDate()">
</apex:commandButton>
</apex:form>
</apex:page>
Govenor Limits:
What are Apex Governor Limits?
Governor limits are runtime limits enforced by the Apex runtime engine.
Because Apex runs in a shared, multitenant environment, the Apex runtime
engine strictly enforces a number of limits to ensure that code does not
monopolize shared resources. Types of limits that Apex enforces are
resources like memory, database resources, number of script statements to
avoid infinite loops, and number of records being processed. If code exceeds
a limit, the associated governor issues a runtime exception.
Description
Total number of SOQL queries issued
Total number of SOQL queries issued for Batch Apex and future
methods
Total number of records retrieved by SOQL queries
Total number of SOSL queries issued
Total number of records retrieved by a single SOSL query
Total number of DML statements issued2
Total number of records processed as a result of DML
statements, Approval.process, or database.emptyRecycleBin
Total number of executed code statements
55

Limit
100
200
50,000
20
2000
150
10,000
200,000

Total number of executed code statements for Batch Apex and


future methods
Total heap size
Total heap size for Batch Apex and future methods
Total stack depth for any Apex invocation that recursively fires
triggers due to insert, update, or delete statements

1,000,000

For loop list batch size


Total number of callouts (HTTP requests or Web services calls)
in a request
Maximum timeout for all callouts (HTTP requests or Web
services calls) in a request
Default timeout of callouts (HTTP requests or Web services
calls) in a request
Total number of methods with the future annotation allowed
per Apex invocation
Maximum size of callout request or response (HTTP request or
Web services call)
Total number of sendEmail methods allowed
Total number of describes allowed7
Total number of classes that can be scheduled concurrently

200
10

6MB
12MB
16

120
seconds
10 seconds
10
3MB
10
100
25

Writing Trigger between two objects:


Scenario:
Update status and stage fields in job application object when the record is
created in offer object.
trigger UpdateStatusAndStageFieldsInParent on Offer__c (before insert) {
for(offer__C o:trigger.new) {
Job_Application__c j=[select name from Job_Application__c where id =:
o.Job_Application__c];
// =: runtime binding or dynamic binding
J.status__c='Approved';
J.stage__C='Offer Extended';
update j;
}
56

}
Test Cases:
1)
2)
3)

Create a record in offer object.


Verify if the record created in offer object?
Verify if below fields are set in job application object?
Status to 'Approved'
Stage to 'Offer Extended'

Bulkify Triggers:
we write bulkify triggers to make sure the code properly handles more than one
record at a time. There are cases where a single instance of that Apex code is
executed, but it needs to handle all of the records in that given batch. So, the
records need to be processed as a bulk to avoid hitting governor limits.
Instead of assigning trigger.new[0] to an object write a for loop for all records in
that batch:
Example:
Account a= trigger.new[0];
List<Contact> contacts = [select id, salutation, firstname, lastname,
email from Contact where accountId = :acct.Id];
The above code works perfectly fine when the trigger fired to process just one
record and the same code fails if the trigger fired to process more than one records.
In such cases, we need to write:
for (account a:tigger.new)
Which processes records upto 200 without hitting governor limits.
Example: (Bulkify Trigger):
trigger RejDups on Account (before insert) {
list<account> allaccounts=[select name from account];
for(account newaccount:trigger.new)
for (account oneaccount:allaccounts)
if(newaccount.name==oneaccount.name)
57

newaccount.adderror('Duplicate record, Can not be inserted');


}
Example:(Trigger for one record):
trigger RejDups on Account (before insert) {
list<account> allaccounts=[select name from account];
account newaccount=trigger.new[0];
for (account oneaccount:allaccounts)
if(newaccount.name==oneaccount.name)
newaccount.adderror('Duplicate record, Can not be inserted');
}
Customer Relationship Management:
CRM is a customer relationship management system. A CRM system allows
businesses to manage business relationships and the data and information
associated with them. With CRM, you can store customer contact information,
accounts, leads and sales opportunities in one central location, ideally in the cloud
so the information is accessible by many, in real time.
Wrapper Classes:
A wrapper or container class is a class whose instances are a collections of other
objects.
For example, if there are 20 records for an object and you would to update selected
records then we write wrapper class controller and vfpage.
Webservices:
https://developer.salesforce.com/page/Apex_Web_Services_and_Callouts

58

1) Do you know about triggers? What is trigger? Have you used


triggers?
A trigger is apex code that executes based on trigger events. The trigger events
are:
before insert
before update
before delete
after insert
after update
after delete
after undelete
5) Do you know trigger context variables? What is trigger context
varaibles?
All triggers define implicit variables that allow developers to access
runtime context. These variables are contained in the System.Trigger
class:
Variable
isExecuting

isInsert

isUpdate

isDelete
isBefore
isAfter
isUndelete

Usage
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.
Returns true if this trigger was fired due to an insert
operation, from the Salesforce user interface, Apex, or
the API.
Returns true if this trigger was fired due to an update
operation, from the Salesforce user interface, Apex, or
the API.
Returns true if this trigger was fired due to a delete
operation, from the Salesforce user interface, Apex, or
the API.
Returns true if this trigger was fired before any record
was saved.
Returns true if this trigger was fired after all records were
saved.
Returns true if this trigger was fired after a record is
59

Variable

Usage
recovered from the Recycle Bin (that is, after an undelete
operation from the Salesforce user interface, Apex, or the
API.)
Returns a list of the new versions of the sObject
records.

new

Note that this sObject list is only available in


insert and update triggers, and the records can
only be modified in before triggers.
A map of IDs to the new versions of the sObject records.

newMap

Note that this map is only available in before update,


after insert, and after update triggers.
Returns a list of the old versions of the sObject
records.

old

Note that this sObject list is only available in


update and delete triggers.
A map of IDs to the old versions of the sObject records.

oldMap

size

Note that this map is only available in update and delete


triggers.
The total number of records in a trigger invocation, both
old and new.

We used triggers in our application(Patient Service Application) to make sure


we have all the information required to send query to the doctor.
Written a trigger to make sure if the medical number is valid? The trigger
throws an error if the number is not a valid medical number.
Written a trigger to list all the doctors in that specialization if the patient's
doctor has resigned from this hospital. For example patients with chronic
deceases will take an appointment once in a year and the doctor might have
resigned during this period.

60

2) What is the difference between customer controller and


controller extension?
A Custom controller is an Apex Class that implements custom functionality. We
use custom controller when we want your VF page to run system mode.
System Mode in which salesforce does not enforce the permissions on field level
security of the current user.
Controller Extension- An apex class having a public constructor with Custom
controller or Standard Controller as a single argument known as controller
extension. Controller extension will allow us to add new functionality by using the
existing standard or custom controllers.
For example: If we have controller for specific functionality and used by a multiple
pages and if one of the pages needs some extract logic, then we need to write
controller extension instead of updating the controller.
3) Do you know transient keyword? What is transient keyword?
We use transient keyword to declare instance variables that can't be saved, and
shouldn't be transmitted
from one Visualforce page to another
visualforce page.
4) What is view state? How do you reduce the size of view state?
Visualforce pages that contain a form component also contain an encrypted,
hidden form fields that encapsulate the view state of the page. The view state is
automatically created and it holds the state of the pages, state that includes the
components, field values and controller state.
To reduce view state:
- Use transient variables
- Minimize number of forms on a page.
- Refine your SoQL to only retrieve the data needed by the page only.
View State Error Example:
I have recived an error that 'Maximum view state size limit (135KB) exceeded.
Actual view state size for this page was 190.2KB' for one of the Visualforce page
we used.

What is exception? Have you ever worked on exceptions?


Yes.. I have experience in creating exceptions.
Exceptions are run time errors. There are different built in exceptions such are:
DML Exceptions
61

Null Pointer Exceptions


Sobject Exceptions
Email Exceptions
List Exceptions
query Exception
Common Exception Methods:
getCause
getLineNumber
getMessage

Returns the cause of the exception as an exception object.


Returns the line number from where the exception was
thrown.
Returns the error message that displays for the user.

What is custom exception? Have you ever used custom exception?


We can create our own exceptions by extending our exceptions from exception
class.
And we can use the methods already defined in Exception class such as Exception
with no argument, with one argument and with two arguments, etc..
What are the differences between LIST & Set?
Both of them are collection data types.
List is a ordered collection and allows duplicates.
Set is a unordered collection and does not allow duplicates
What do you know about map?
Map is a collection data type and it is Key and Value pair. For example:
Doctor ID and Doctor Name:
1, Steve Coskie
2, Craig Lapiana
etc..
The differences between List and Map? Can we write List in Map and
Map in List? Can you give any example?
public class ListMap
{
public void display()
62

{
list<integer> li=new list<integer>();
li.add(25);
li.add(35);
map<integer, list<integer>> mli=new map<integer, list<integer>>();
mli.put(25,li);
mli.put(35,li);
list<map<integer,
list<integer>>>();
lma.add(mli);

list<integer>>>

lma=new

list<map<integer,

}
}
Do you know about access modifiers? What is access modifiers? How
many types of modifiers?
There are four types of access modifiers in salesforce:
Private It is by default, Accessible within the class.
Protected Accessible with in the class and it's sub class.
Public Accessible with in the application or with in the namespace.
Global Accessible outside of the application as well, if the method is global then
the class name must be global.
What is constructor? Do you know anything about constructors?
Constructor do have the same name as class and it does not return any value.
For Example:
Class Doctor
{
Doctor()
{
}
}
What are the static variables & methods? Where do you use them?
Static methods which are associated with the class, not with the instance (object).
We can call static methods & variables using class name.
For Example:

63

Class Doctor
{
static void method1()
{
}
}
We can call method1 using class name. For example: Doctor.method1();
How do you define constants(final) in salesforce?
We use final keyword to declare constants. For Example, Hospital address will
not be changed very often. So, we can declare Hospital address as final.
Final Address = '1 Mall Road, Burlington,MA 01803';

What is sObject?
sObject is a abstract object type. We can assign any standard object or custom
object to sObject such as an account or the Invoice_Statement__c custom object.
Do you know about SoSL or SoQL? When do we use them?
Salesforce Object Query Language (SOQL) is a query language for data operations
of a single sOobject and its related sObjects. We Can't use SoQL for Joins.
Salesforce Object Search Language (SOSL) is a search language for searching
across all multiple objects simultaneously.
What is DML statements? And the database operations? What are the
differences between them?
We use data manipulation language (DML) operations to insert, update,
delete, and restore data in a database.
The following Apex DML operations are available:

delete - To delete a record/records


Insert - To insert a record/records
undelete To recover deleted records
update - To update existing records
upsert - To update existing records and insert new records.

Database class methods:


The Database DML methods take a single sObject or a list of sObjects as their
first argument. They also take a second optional Boolean argument that specifies
64

whether the operation allows for partial success. If set to false and a record
fails, the remainder of the DML operation can still succeed. The Database
DML methods return the results to Database.SaveResult[].
The difference:
When we are inserting more number of records and if there is any problematic
record then DML statement stops insert at that record whereas database class
insert method proceed with next record and save the results.
Have you ever used eclipse? Do you use any tools?
Yes.. we use eclipse to write our code.
What are differences between Enterprise WSDL and Partner WSDL?
Enterprise
WSDL
A strongly typed WSDL for customers who want to build an integration with their
salesforce.com organization only.
Partner
WSDL
A loosely typed WSDL for customers, partners, and ISVs who are building client
applications for multiple organizations. It can be used to access data within any
organization.
We can generate Apex classes from WSDL Files by selecting Generate From
WSDL from Apex Classes.

Q10) Can we schedule a data loader?


The data loader does not offer scheduling capabilities like Informatica Data
Loader. However, you can invoke the data loader using the scheduler provided by
your system OS (e.g. Windows Scheduler) to call a .bat (batch file) that will in turn
call the Data Loader config file, which will automatically login to the Data Loader
using the credentials (Username, Password and Security token) that you provide
in the config file and perform the operation described in the config file.
This method is called Data Loader Command Line Interface (CLI).

Q11) how to schedule apex data loader batch job?


You will want to run Data Loader from the command line using Scheduler to run
the processes. if it is Windows then you will need to use the Task Scheduler.

65

Q12) Is there any way to prevent record view for a person high in role
hierarchy?
Yes.. We can do so if the user in role hierarchy does not have permission on that
object in his profile.

1.what are the global variables ?


Use global variables to reference general information about the current user and
your organization on a visualforce page.
Global variables must be referenced using Visualforce expression syntax to be
evaluated, for example, {!$User.Name}.
2. Communication Templates [email templates]
Letterheads
Email Templates
Mail Merge Templates
Email Templates:
You can create four different types of email templates:
Text All users can create or change text email templates.
HTML with letterhead Administrators and users with the Edit HTML

Templates permission can create HTML email templates based on a


letterhead.
Custom HTML Administrators and users with the Edit HTML
Templates permission can create custom HTML email templates without
using a letterhead. You must either know HTML or obtain the HTML code
to insert in your email template.
Visualforce Administrators and developers can create templates
using Visualforce. Visualforce email templates allow for advanced merging
with a recipients data, where the content of a template can contain
information from multiple records,
3.Explain how do you used Action function ?
Action methods perform logic or navigation when a page event occurs, such as
when a user clicks a button, or hovers over an area of the page. Action methods
can be called from page markup by using {! } notation in the action parameter of
66

one of the following tags:


<apex:commandButton> creates a button that calls an action
<apex:commandLink> creates a link that calls an action
<apex:actionPoller> periodically calls an action
<apex:actionSupport> makes an event (such as onclick, onmouseover, and
so on)
on another, named component, call an action
<apex:actionFunction> defines a new JavaScript function that calls an action
<apex:page> calls an action when the page is loaded
Example:
<apex:page standardController="account">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection>
<apex:inputField value="{!account.name}"/>
<apex:inputField value="{!account.industry}"/>
<apex:inputField value="{!account.numberofemployees}"/>
<apex:commandButton action="{!save}" value="Save" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
4.Tell me about tags in visual force page?
Visualforce is the component-based user interface framework for the Force.com
platform. The
framework includes a tag-based markup language, similar to HTML.
The examples are:
<apex:page>
<apex:datatable>
<apex:image>
<apex:detail>
5.What are custom labels and how did you use ?
Custom labels are custom text values that can be accessed from Apex classes or
Visualforce pages. The values can be translated into any language Salesforce
supports. Custom labels enable developers to create multilingual applications by
automatically presenting information (for example, help text or error messages)
in a user's native language.
You can create up to 5,000 custom labels for your organization, and they can
be up to 1,000
characters in length.

67

What is the difference between Implements and Extends?


A class can be extended from other class (which has methods defined in it)
where a class can be implemented from other interface( which has declarations
in it).

Have you ever used Webservices like REST API or SOAP API?
Yes.. we tested REST using workbench tool provided by salesforce for Testing and
SOAP API tested with Strike Iron. StrikeIron is the cloud company to provide
reliable Data-as-a-Service (DaaS) platform in the market. They give 30 day free
access for testing Email Verification, Phone Number verification. For example:
When we give phone number then we get the complete address of the phone
number.

1. What is Apex
It is the in-house technology of salesforce.com which is similar to Java
programming with object
oriented concepts and to write our own custom logic.
2. Is it possible to write the Apex code from user Interface?
You can add, edit, or delete Apex using the Salesforce.com user interface only in
a Developer
Edition organization, a Salesforce.com Enterprise Edition trial organization, or
sandbox
organization. In a Salesforce.com production organization, you can only make
changes to Apex
by using the Metadata API ,deploy call, the Force.com IDE, or theForce.com
Migration Tool.
The Force.com IDE and Force.com Migration Tool are free resources provided by
salesforce.com
to support its users and partners, but are not considered part of our Services for
purposes of the
salesforce.com Master Subscription Agreement.
3. In How many ways we can invoke the Apex class?
a. Triggers
b. Web Services
68

c. Email Services
d. Batch Classes
e. Schedulable Classes
f. Test Classes
g. Controller Classes for Visualforce pages
4. What is a class and explain in detail?
Apex classes are similar to Java classes.
A class is a template or blueprint from which Apex objects are created. Classes
consist of other
classes, user-defined methods, variables, exception types, and static initialization
code. They are
stored in the application under Setup, in Develop | Apex Classes.
An Apex class can contain variables and methods.
Variables are used to specify the state of an object, such as the object's name or
type. Since
these variables are associated with a class and are members of it, they are referred
to as
member variables.
Methods are used to control behavior, such as purchasing or selling an item.
Methods can also contain local variables that are declared inside the method and
used only by
the method. Whereas class member variables define the attributes of an object,
such as name
or height, local variables in methods are used only by the method and dont
describe the class.
5. What is the Syntax for a Class?
6. What are Access Modifiers in SalesForce?
Apex allows using the private, protected, public, and global access modifiers when
defining
methods and variables.
public
This means the method or variable can be used by any Apex in this application or
namespace.
global
This means the method or variable can be used by any Apex code that has access
to the class,
not just the Apex code in the same application. This access modifier should be
used for any
method that needs to be referenced outside of the application, either in the SOAP
API or by
other Apexcode. If we declare a method or variable as global, we must also declare
69

the class that


contains it as global.
private
This is the default, and means that the method or variable is accessible only within
the Apex class in which it is defined. If we do not specify an access modifier, the
method or
variable is private
protected
This means that the method or variable is visible to any inner classes in the
defining Apex class.
We can only use this access modifier for instance methods and member variables.
Note that it is
strictly more permissive than the default (private) setting, just like Java.
7. What is an Object?
object is an instance of a class. For example, a Fridge class describes the state of a
fridge and
everything we can do with it. An instance of the Fridge class is a specific
refrigerator that can be
purchased or sold.
8. How do you instantiate a Class?
ClassName objS = New ClassName();
9. What is an Instance Method?
Instance methods and member variables are used by an instance of a class, that
is, by an object.
Instance member variables are declared inside a class, but not within a method.
Instance
methods usually use instance member variables to affect the behavior of the
method.
instance methods and variables, which means you have to first create an instance
of the class to
use. Each individual instance has its own copy of instance variables, and the
instance methods
can access these variables.
10.What is a Static Method?
Static methods are methods declared with the static keyword. Theyre generally
useful as utility
methods and never depend on a particular instance member variable value.
Because you can
only associate a static method with a class, the static method cannot access any
instance
member variable values of the class. Static variables are only static within the
70

scope of the request. They are not static across the server, or across the entire
organization.
When you need to have a member variable whose value is available to all instances
need to
create a static variable. Static variables are associated with the class and not the
instance and
you can access them without instantiating the class.
11.What is the scope of static variable?
When you declare a method or variable as static, its initialized only once when a
class is loaded.
Static variables arent transmitted as part of the view state for a Visualforce page.
Static variables are only static within the scope of the request. They are not static
across the
server, or across the entire organization.
12.What are the Keywords in SalesForce?
Apex has the following keywords available:
final
instanceof
super
this
transient
with sharing and without sharing
13.Explain with sharing and without sharing key words?
Apex generally runs in system context; that is, the current user's permissions,
field-level security,
and sharing rules arent taken into account during code execution.
Because these rules aren't enforced, developers who use Apex must take care that
they don't
inadvertently expose sensitive data that would normally be hidden from users by
user
permissions, field-level security, or organization-wide defaults. They should be
particularly
careful with Web services, which can be restricted by permissions, but execute in
system
context once they are initiated.
Use the with sharing keywords when declaring a class to enforce the sharing rules
that apply to
the current user.
14.What is an Interface?
An interface is a named set of method signatures (the return and parameter
definitions), but
without any implementation.
71

Interfaces provide a layer of abstraction to your code. They separate the specific
implementation
of a method from the declaration for that method. This way, you can have different
implementations of a method based on your specific application.
15.What is a Sub class?
Apex supports subclasses, allowing you to create a class that extends another class.
The subclass
inherits all the functionality of that parent class. It can also have additional
methods and
member variables, and can override the behavior of existing parent class methods.
16.What are Primitive Data Types in APEX Language?
Apex has a number of primitive data types. These are used to store data at run
time.
String: Strings are set of characters and are enclosed in single quotes. They store
text values such
as a name or an address.
Integer, Long, Double and Decimal: Variables declared with any of these
data types hold
numeric values.
Time, Date and Datetime: Variables declared with any of these data types hold
time, date, or
time and date values combined
Boolean: Boolean values hold true or false values and you can use them to test
whether a
certain condition is true or false
17.What is ID data type?
The ID data type represents an 18-character an object identifier. Force.com sets
an ID to a object
once it is inserted into the database. For example, an ID value can be
a02D0000006YLCyIAO.
18.What are Collection Objects?
Apex has the following types of collections:
Lists
Maps
Sets
A list is a collection of elements, such as Integers, Strings, objects, or other
collections.
List holds an ordered collection of objects.
Use a list when the sequence of elements is important. List can have duplicate
elements .
The index position of the first element in a list is always 0.
72

A set is an unordered collection of elements that do not contain any duplicates.


Set elements
can be of any data typeprimitive types.
Apex uses a hash structure for all sets.
A set is an unordered collection. Do not rely on the order in which set results are
returned. The
order of objects returned by sets may change without warning.
A map is a collection of key-value pairs where each unique key maps to a single
value. Key can be
primitive data type and value can be any data typeprimitive types, collections,
sObjects, userdefined
types, and built-in Apex types.
19.What is a SObject?
sObject is a generic abstract type that corresponds to any persisted object type.
The generic
sObject can be cast into a specific sObject type, such as an account
An sObject is any object that can be stored in the Force.com platform database.
These are not
objects in the sense of instances of Apex classes; rather, they are representations
of data that
has or will be persisted.
sObject s = new Account();
22.Rolling Back Transactions and Savepoints
Apex supports rolling back transactions. You can generate a savepoint which sets
a point in the
request that corresponds to a state in the database. Any DML statement that
occurs after the
savepoint can be discarded and the database can be restored to the same initial
condition.
23. Locking Statements
Apex allows you to lock an sObject record to prevent other code from making
changes to it. Use
the FOR UPDATE SOQL statement to lock a record.
24.What is an Exception?
Exceptions note errors and other events that disrupt the normal flow of code
execution. Throw
statements are used to generate exceptions, while try, catch, and finally
statements are used to
gracefully recover from exceptions.
73

The advantage of using exceptions is that they simplify error handling. Exceptions
bubble up
from the called method to the caller, as many levels as necessary, until a catch
statement is
found that will handle the error.
using finally statements, we have one place to recover from exceptions, like
resetting variables
and deleting data.
When an exception occurs, code execution halts and any DML operations that
were processed
prior to the exception are rolled back and arent committed to the database.
Exceptions get
logged in debug logs. For unhandled exceptions, that is, exceptions that the code
doesnt catch,
Salesforce sends an email to the developer with the organization ID and user ID
of the running
user, as well as the exception message.
If you run into an exception that occurred in Apex code while using the standard
user interface,
an error message appears on the page showing you the text of the unhandled
exception
25. Explain Try, Catch and Finally Statements in SalesForce?
Apex uses try, catch and finally statements to handle exceptions.
The try statement identifies a block of code in which an exception can occur. If
you have code
that you think could generate an exception, wrap this section of your code in a try
block, and add
a catch block after it. Only exceptions thrown from the code wrapped in the try
block are
handled by the catch block.
The catch statement identifies a block of code that handles a particular type of
exception. In the
previous example, notice that there are two catch statements. You can have as
many catch
statements as you like, one for each exception type you want to catch.
The finally statement is optional and gets executed after the catch block executes.
Code in the
finally block always executes regardless of the type of exception that was thrown
and handled.
You can add any final clean up code here.
26. Explain some Built In Exceptions?
DML Exception
74

List Exception
NullPointerException
QueryException
SObjectException
27. How to create Custom Exception?
To create custom exception class, extend the built-in Exception class and make
sure class name
ends with the word Exception. Append extends Exception after class declaration
public class MyException extends Exception {}
28.What are different annotations in SalesForce?
An Apex annotation modifies the way a method or class is used, similar to
annotations in Java.
Annotations are defined with an initial @ symbol, followed by the appropriate
keyword. To add
an annotation to a method, specify it immediately before the method or class
definition. For
example:
global class MyClass {
@future
Public static void myMethod(String a)
{
//long-running Apex code
}
}
Apex supports the following annotations:
@Deprecated
@Future
@IsTest
@ReadOnly
@RemoteAction
@TestVisible
Apex REST annotations:
@RestResource(urlMapping='/yourUrl')
@HttpDelete
@HttpGet
@HttpPatch
@HttpPost
@HttpPut
29.What is a Test Class in SalesForce?
To facilitate the development of robust, error-free code, Apex supports the
75

creation and
execution of unit tests. Unit tests are class methods that verify whether a
particular piece of
code is working properly.
Unit test methods take no arguments, commit no data to the database, send no
emails, and are
flagged with the testMethod keyword or the isTest annotation in the method
definition.
Classes defined with the isTest annotation don't count against your organization
limit of 3
MB for all Apex code.
At least 75% of your Apex code must be covered by unit tests
Also, test methods must be defined in test classes, that is, classes annotated with
isTest.
@isTest
private class myClass {
static testMethod void myTest() {
code_block
}
}
@isTest
private class myClass {
@isTest static testMethod void myTest() {
code_block
}
}
Test methods cant be used to test Web service callouts. Instead, use mock callouts.
See Testing
Web Service Callouts and Testing HTTP Callouts.
We cant send email messages from a test method.
Since test methods dont commit data created in the test, we dont have to delete
test data
upon completion.
30.Explain System.runAs()
Generally, all Apex code runs in system mode, and the permissions and record
sharing of the
current user are not taken into account. The system method, System.runAs(),
lets you write test
methods that change user contexts to either an existing user or a new user. All of
that users
record sharing is then enforced. You can only use runAs in a test method.
The original system
76

context is started again after all runAs() test methods complete.


Example :
1 System.runAs(u) {
2 // The following code runs as user 'u'
3 System.debug('Current User: ' + UserInfo.getUserName());
4 System.debug('Current Profile: ' + UserInfo.getProfileId());
5 // Run some code that checks record sharing
}
31.What are Apex Governor Limits?
Governor limits are runtime limits enforced by the Apex runtime engine. Because
Apex runs in a
shared, multitenant environment, the Apex runtime engine strictly enforces a
number of limits
to ensure that code does not monopolize shared resources. Types of limits that
Apex enforces
are resources like memory, database resources, number of script statements to
avoid infinite
loops, and number of records being processed. If code exceeds a limit, the
associated governor
issues a runtime exception.
32. Do governor limits apply to sandbox instances?
Governor limits do apply to all Salesforce instances (trial, developer, production
or sandbox
environments). However code coverage and successful execution of test classes is
only enforced
when deploying to a production environment.
33. In Which sequence Trigger and automation rules run in
Salesforce.com
The following is the order salesforce logic is applied to a record.
1. Old record loaded from database (or initialized for new inserts)
2. New record values overwrite old values
3. System Validation Rules
4. All Apex before triggers (EE / UE only)
5. Custom Validation Rules
6. Record saved to database (but not committed)
7. Record reloaded from database
8. All Apex after triggers (EE / UE only)
9. Assignment rules
10. Auto-response rules
11. Workflow rules
12. Escalation rules
13. Parent Rollup Summary Formula value updated (if present)
77

14. Database commit


15. Post-commit logic (sending email)
Additional notes: There is no way to control the order of execution within each
group
above.
34. If one object in Salesforce have 2 triggers which runs before
insert. Is there any way to
control the sequence of execution of these triggers?
Salesforce.com has documented that trigger sequence cannot be predefined.
As a best practice
create one trigger per object and use comment blocks to separate different logic
blocks. By
having all logic in one trigger you may also be able to optimize on your SOQL
queries.
35.What is a Trigger?
Triggers are Apex code that execute before or after an insert, update, delete or
undelete event occurs on an
sObject.
A trigger always starts with the trigger keyword, followed by the name of the
trigger, the database object to
which the trigger should be attached to, and then the conditions under which it
should fire
trigger triggerName on ObjectName (trigger_events) {
code_block
}
The events you can specify are:
before insert
before update
before delete
after insert
after update
after delete
after undelete
36.What is the difference between trigger.new and trigger.old in Apex
SFDC?
Trigger.new :
Returns a list of the new versions of the sObject records.
Note that this sObject list is only available in insert and update triggers, and
the records can only
be modified in before triggers.
Trigger.old :
Returns a list of the old versions of the sObject records.
78

Note that this sObject list is only available in update and delete triggers.
37.How to restrict any Trigger to fire only once? Or What is Recursive
Triggers?
You want to write a trigger that creates a new record as part of its processing logic;
however, that
record may then cause another trigger to fire, which in turn causes another to fire,
and so on. You
don't know how to stop that recursion.
The before and after triggers fire one more time only if something needs to be
updated. If the
fields have already been set to a value, the triggers are not fired again.
Workaround:
Create a Helper Class, with a static Boolean variable.
Check its value within the affected triggers.
After the trigger is executed , set the Boolean to True.
Class HelperForTriggerA{
public static TriggerExecuted = False;
}
Trigger on Account(After Insert){
if (HelperForTriggerA.TriggerExecuted ==False){
Code Block
HelperForTriggerA.TriggerExecuted ==True;
}
}
38. In class declaration if we dont write keyword with sharing then
it runs in system mode then
why keyword without sharing is introduced in apex?
Lets take example, there is classA declared using with sharing and it calls
classB method.
classB is not declared with any keyword then by default with sharing will be
applied to that
class because originating call is done through classA. To avoid this we have to
explicitly define
classB with keyword without sharing.
39.What is Scheduler class in Apex?
The Apex class which is programmed to run at pre defined interval.
Class must implement schedulable interface and it contains method named
execute().
There are two ways to invoke scheduler :
1. Using UI
2. Using System.schedule
The class which implements interface schedulable get the button texted with
79

Schedule, when
user clicks on that button, new interface opens to schedule the classes which
implements that
interface.
To see what happened to scheduled job, go to Monitoring | Scheduled jobs
40.What is difference in ISNULL and ISBLANK?
ISNULL:
Determines if an expression is null (blank) and returns TRUE if it is. If it contains
a
value, this function returns FALSE.
Text fields are never null, so using this function with a text field always returns
false. For
example, the formula field IF(ISNULL(new__c) 1, 0) is always zero regardless of
the value in
the New field. For text fields, use the ISBLANK function instead.
Multi-select picklist fields are never null in s-controls, buttons, and email
templates, so
using this function with a multi-select picklist field in those contexts always
returns false.
Empty date and date/time fields always return true when referenced in ISNULL
functions.
Choose Treat blank fields as blanks for your formula when referencing a number,
percent, or currency field in an ISNULL function. Choosing Treat blank fields as
zeroes gives
blank fields the value of zero so none of them will be null.
Merge fields can be handled as blanks, which can affect the results of
components like scontrols
because they can call this function.
When using a validation rule to ensure that a number field contains a specific
value, use
the ISNULL function to include fields that do not contain any value. For example,
to validate
that a custom field contains a value of 1, use the following validation rule to
display an
error if the field is blank or any other number: OR(ISNULL(field__c),
field__c<>1)
ISBLANK:
Determines if an expression has a value and returns TRUE if it does not. If it
contains a
value, this function returns FALSE.
Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same
functionality as
80

ISNULL, but also supports text fields. Salesforce.com will continue to support
ISNULL, so you
do not need to change any existing formulas.
A field is not empty if it contains a character, blank space, or zero. For example,
a field
that contains a space inserted with the spacebar is not empty.
Use the BLANKVALUE function to return a specified string if the field does not
have a
value; use the ISBLANK function if you only want to check if the field has a value.
If you use this function with a numeric field, the function only returns TRUE if
the field
has no value and is not configured to treat blank fields as zeroes.
41. What is the dynamic Apex?
Dynamic Apex enables developers to create more flexible applications by
providing them with
the ability to Access sObject and field describe information, Write
Dynamic SOQL Queries,
Write Dynamic SOSL Queries and Dynamic DML.
42.What is a Visualforce Page ?
Visualforce is the new markup language from salesforce, by using which, We can
render the
standard styles of salesforce. We can still use HTML here in Visualforce. Each
visualforce tag
always begins with apex namespace. All the design part can be accomplished by
using
Visualforce Markup Language and the business logic can be written in custom
controllers
associated with the Page
43.Where to write Visualforce code ?
You can write the code basically in 3 ways.
1. setup->App Setup->Develop->Pages and create new Visulaforce page.
2. Setup -> My Personal Information -> Personal Information -> Edit checks the
checkbox
development mode. When you run the page like this,
https://ap1.salesforce.com/apex/MyTestPage. you will find the Page editor at the
bottom of
the page. You can write you page as well as the controller class associated with it,
there it
self.
3. Using EclipseIDE you can create the Visulaforce page and write the code.
44. Explain the MVC design pattern of Salesforce.com
Model view controller (MVC) design pattern is the one of the most popular design
81

pattern in 3 tier
applications. 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. One normal questions
asked in salesforce is
explaining the MVC behavior of the application.
So lets discuss that how Salesforce.com uses MVC pattern.
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
45.How to display error messages in the visualforce page ?
In Apex use below code to create the error message for visualforce.
1
Apexpages.addMessage(
new
ApexPages.Message
(ApexPages.Severity.ERROR,'Required fields are
missing. '));
in Visualforce page add below tag where you want to display the error message.
<apex:pageMessages ></apex:pageMessages>
46.What is the controller extension?
Any apex class having a public constructor with Custom Controller or Standard
Controller object
as a single argument is known as controller extension.
47.How many controllers can be used in a visual force page?
we can use only ONE controller at a time in VF page, it could be either standard
or custom controller. But we can has as many as extensions that we need.
47a) What if we have the same method in all extensions?

82

For eample: Ext1 has display(), Ext2 has display(), Ext3 has display() as well then
which method would be called when we click on button.
They go order.
<apex:page controller="CustomerController" extensions="Ext1, Ext2, Ext3">
then display() in Ext1 will be called.
<apex:page controller="CustomerController" extensions="Ext2, Ext3, Ext1">
then display() in Ext2 will be called.

48.What is difference between component and controller?


Component is nothing but it type of Programming function, which we can use to
encapsulate
common design patterns and then reuse those patterns in one or more.
Controller.. this is a class used to derive you custom business functionality
49.Explain the need or importance of the controller extension.
Controller extension is very useful and important concept introduced by the
salesforce recently.
It gives the power to programmer to extend the functionality of existing custom
controller or
standard controller.
A Visualforce can have a single Custom controller or standard controller but many
controller
extensions.
we can say that the custom extension is the supporter of custom or standard
controller.
Consider one example : If there is one controller written and used by the multiple
visualforce
pages and one of them needs some extra logic. Then instead of writing that logic
to controller
class (Which is used by many visualforce pages) we can create a controller
extension and apply
to that page only.
50.What is S-Control ?
Ans: S-Controls are the predominant salesforce.com widgets which are
completely based on
Javascript. These are hosted by salesforce but executed at client side. S-Controls
are superseded
by Visualforce now.
51.What is Difference in render, rerender and renderas attributes of
visualforce?
83

render It works like display property of CSS. Used to show or hide element.
rerender After Ajax which component should be refreshed available on
commandlink,
commandbutton, actionsupport etc.
renderas render page as pdf, doc and excel.
52.What are the types of controller in visual force?
There are basically two types of Controller in Visual force page.
1. Standard Controller and
2. Custom Controller
53.How many Controllers can be used on single VF page?
Only one controller can be used salesforce. Other than them, Controller
extension can be
used. There may be more than one Controller extension.
Example :
<apex:page standardController="Account" extensions="ExtOne,ExtTwo"
showHeader="false">
<apex:outputText value="{!foo}" />
</apex:page>
if ExtOne and ExtTwo, both have the method getFoo() then the method of
ExtOne will be
executed.
A controller extension is any Apex class that contains a constructor that takes a
single
argument
of
typeApexPages.StandardController
or
CustomControllerName, where
CustomControllerName is the name of a custom controller that you want to
extend.
54.What is the need of Custom Controller in Visualforce as
everything can be done by the
combination of Standard Controller + Extension class.
a. Sharing setting is applied on standard object/extension by default; In case we
dont want
to apply sharing setting in our code then Custom controller is only option.
b. It is possible that the functionality of page does not required any Standard
object or may
require more than one standard object, then in that case Custom controller is
required.
55.How to implement the pagination in SOQL ?
In spring 12, Salesforce has come up with ability of SOQL to get records from
position X instead
of position 1 every time to help creating pagination feature
56. Difference between Sandbox and Development environment?
84

A test environment for salesforce.com is crucial to change control. Salesforce.com


provides the
tools needed to test anything in a test environment before you implement it in
your live
instance. You can either test in a Sandbox environment or in a Developer
environment. What is
the difference? I will share what I know
Sandbox
The salesforce.com Sandbox environment is an exact copy of your salesforce.com
instance. You
can copy your live instance to a sandbox environment (but you have to perform
manually from
sandbox to developer edition) where you can test any changes, implementations,
AppExchange
apps or updates. It can also be your hands-on training environment without
risking your live
data.
You can either copy your configuration and data into a sandbox environment or
just the
configuration. It acts exactly like your live instance, but be careful if you have
workflow rules or
automations because they will work in the sandbox as well.
I know that this sounds wonderful and if you dont have it, you are dying to know
how to get it.
The problem is the cost. If you are on Unlimited Edition, then cost is not a problem
because it
comes included. But for Enterprise, Professional or Group Editions, you have to
pay and the
price is hefty; anywhere between 25k-50k per year. For a lot of companies, that is
more than
they are paying for their live salesforce.com instance. So how do you test
salesforce.com without
Sandbox? It is always suggested to develop application in sandbox instance then
go for LIVE.
Developer Edition
Developer Edition was an edition created for development of integrations and
apps, specifically
for the AppExchange. It is also a great tool for testing/training in salesforce.com.
What makes
this a great tool is the fact that it is free. Anyone can get a Developer Edition of
salesforce.com. It
is a standard Enterprise Edition with very limited storage space. You cannot copy
85

your
configuration or data onto the Developer Edition, but you can customize it to
match your
instances look and feel. Once it is customized, you can use it for training, testing
or anything else
you want. It takes a little bit of work, but you can make it act and feel just like your
live instance.
The work is well worth it for the free price.
57.How to get the list of all available sobject in salesforce database
using Apex (Dynamic Apex)?
Map<String, Schema.SObjectType> m = Schema.getGlobalDescribe();
58. How to create instance of sobject dynamically?
Normally the sobject is created like Account a = new Account();. But if you are
in situation that
you dont know which sobject is going to be instantiated ? Means it will be decided
at runtime,
how you will handle it?
Hint : Use Dynamic Apex.
public SObject getNewSobject(String t){
// Call global describe to get the map of string to token.
Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
// Get the token for the sobject based on the type.
Schema.SObjectType st = gd.get(t);
// Instantiate the sobject from the token.
Sobject s = st.newSobject();
return s;
}
59. How to get all the fields of sObject using dynamic Apex?
1 Map<String, Schema.SObjectType> m = Schema.getGlobalDescribe() ;
2 Schema.SObjectType s = m.get('API_Name_Of_SObject') ;
3 Schema.DescribeSObjectResult r = s.getDescribe() ;
4 Map<String,Schema.SObjectField> fields = r.fields.getMap() ;
60.How to get all the required fields of sObject dynamically?
There is no direct property available in Apex dynamic API to represent the
required field.
However there is another way to know about it.
If any fields have below three properties then it is mandatory field.
1. If it is Creatable
2. If it is not nillable and
3. If it does not have any default value
61.How to get the picklist value in Apex class?
Using Dynamic apex, we can achieve this.on object of type pickilist, call
86

getDescribe(). then call


thegetPicklistValues() method. iterate over result and create a list. bind it to
<apex:selectOptions>.
62.What is the custom settings?
Custom settings are similar to custom objects and enable application developers
to create
custom sets of data, as well as create and associate custom data for an organization,
profile, or
specific user. All custom settings data is exposed in the application cache,
which enables
efficient access without the cost of repeated queries to the database. This data can
then be
used by formula fields, validation rules, Apex, and the Web services API.
63.Types of the custom settings?
List Custom Settings
A type of custom setting that provides a reusable set of static data that can be
accessed across
your organization. If you use a particular set of data frequently within your
application, putting
that data in a list custom setting streamlines access to it. Data in list settings
does not vary with
profile or user, but is available organization-wide. Examples of list data
include two-letter state
abbreviations, international dialing prefixes, and catalog numbers for products.
Because the
data is cached, access is low-cost and efficient: you dont have to use SOQL queries
that count
against your governor limits.
Hierarchy Custom Settings
A type of custom setting that uses a built-in hierarchical logic that lets you
personalize settings
for specific profiles or users. The hierarchy logic checks the organization, profile,
and user
settings for the current user and returns the most specific, or lowest, value. In
the hierarchy,
settings for an organization are overridden by profile settings, which, in turn, are
overridden by
user settings
64.Other than SOQL and SOSL what is other way to get custom settings?
Other than SOQL or SOSL, Custom seting have their own set of methods to access
the record.
For example : if there is custom setting of name ISO_Country,
87

1 SO_Country__c code = ISO_Country__c.getInstance(INDIA);


2 //To return a map of data sets defined for the custom object (all records in the
custom
object), //you would use:
3 Map<String,ISO_Country__c> mapCodes = ISO_Country__c.getAll();
4 // display the ISO code for India
5 System.debug(ISO Code: +mapCodes.get(INDIA).ISO_Code__c);
6 //Alternatively you can return the map as a list:
7 List<String> listCodes = ISO_Country__c.getAll().values();
65.What is a Callout?
Callouts enable Apex to invoke external web or HTTP services. Apex Web services
allow an
external application to invoke Apex methods through Web services.
Apex provides integration with Web services that utilize SOAP and WSDL, or
HTTP services
(RESTful services).
66.What is a Remote Site Setting?
Before any Apex callout can call an external site, that site must be registered in
the Remote Site
Settings page, or the callout fails. Salesforceprevents calls to unauthorized
network addresses.
To add a remote site setting:
a. From Setup, click Security Controls | Remote Site Settings.
b. Click New Remote Site.
c. Enter a descriptive term for the Remote Site Name.
d. Enter the URL for the remote site.
e. Optionally, enter a description of the site.
f. Click Save.
67.What is REST API?
Representational State Transfer (REST) is a style of software architecture for
distributed
hypermedia systems such as the World Wide Web.
68.What is the default timeout period while calling webservice from
Apex.
10 sec.
69.A single Apex transaction can make how many callouts to an HTTP
request or an API call?
Maximum 10 callouts
70.How to increase timeout while calling web service from Apex ?
docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.timeout_x = 2000; // timeout in milliseconds
71.How to force lead assignment rule via Apex while updating or
88

adding the Lead?


To enforce Assignment Rules in Apex you will need to perform following steps:
1. Instantiate the Database.DMLOptions class.
2. Set the useDefaultRule property of assignmentRuleHeader to True.
3. Finally call a native method on your Lead called setOptions, with the
Database.DMLOptions instance as the argument.
72.How to convert lead using Apex?
1 Lead myLead = new Lead(LastName = 'Foo', Company='Foo Bar');
2 insert myLead;
4 Database.LeadConvert lc = new database.LeadConvert();
5 lc.setLeadId(myLead.id);
7 LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus
WHERE
IsConverted=true LIMIT 1];
8 lc.setConvertedStatus(convertStatus.MasterLabel);
10 Database.LeadConvertResult lcr = Database.convertLead(lc);
11 System.assert(lcr.isSuccess());
SalesForce Application Limits
Enterprise Unlimited
Custom fields 500 800
Custom Relationships 25 25
Active Workflow Rules 50 50
Active Validation Rules 100 300
Approval Processes 500 500
Sharing Rules (CriteriaBased Only)
300 300
Custom Objects 200 2000
Custom Tabs 25 Unlimited
Master Detail Relationships 2 2
Field History Tracking 20 20
Formula 3900 characters (4KB) 3900 characters (4KB)
Web To Lead 500 500
Web to Case 5000 5000
Roles 500 500
Field Filters Per Report 20 20
Formulas Per Report 5 5
Pick List Limits
The maximum number of entries you can have in a picklist is determined by the
total number of characters allowed
89

in the picklist, which is 15,000 characters. Note that each entry includes a
linebreak and a return character that are
not visible. These two additional characters per entry are counted as part of the
15,000 character limit.
Apex Governor Limits
Because Apex runs in a multitenant environment, the Apex runtime engine
strictly enforces a number of limits to
ensure that runaway Apex does not monopolize shared resources.
Description Limit
Total number of SOQL queries issued 100
Total number of SOQL queries issued for Batch Apex and future methods 200
Total number of records retrieved by SOQL queries 50,000
Total number of SOSL queries issued 20
Total number of records retrieved by a single SOSL query 200
Total number of DML statements issued2 150
Total number of records processed as a result of DML statements,
Approval.process, or
database.emptyRecycleBin
10,000
Total number of executed code statements 200,000
Total number of executed code statements for Batch Apex and future methods
1,000,000
Total heap size 6MB
Total heap size for Batch Apex and future methods 12MB
Total stack depth for any Apex invocation that recursively fires triggers due to
insert 16
update, or delete statements 30
For loop list batch size 200
Total number of callouts (HTTP requests or Web services calls) in a request 10
Maximum timeout for all callouts (HTTP requests or Web services calls) in a
request 120 seconds
Default timeout of callouts (HTTP requests or Web services calls) in a request 10
seconds
Total number of methods with the future annotation allowed per Apex invocation
10
Maximum size of callout request or response (HTTP request or Web services call)
3MB
Total number of sendEmail methods allowed 10
Total number of describes allowed7 100
Total number of classes that can be scheduled concurrently 25
90

Object Relationships in SalesForce


Use relationships to associate an object with other objects in Salesforce. You can
define different types of
relationships by creating custom relationship fields on an object.
There four different relationships can be built in Force.com Platform.
Look up (Parent and Child) Two Different Objects
Self Lookup (Same Object) Self Relationship is a lookup relationship on the
same object
Master Detail - This type of relationship closely links objects together such that
the master record controls certain
behaviors of the detail
Many To Many - many-to-many relationships between any two objects
SalesForce has two data types to create relationships. Look up and Master Detail
Look up Relationship
Loosely coupled
Child field may be optional
No cascade Delete
Independent ownership and sharing
Maximum 25 lookup relationships per child object
Master Detail Relationships
Child field value is always required
Cascade Delete
Inherited ownership and sharing
Maximum 2 master relationships per detail object
Many to Many Relationship
A many-to-many relationship allows each record of one object to be linked to
multiple records from another
object and vice versa.
Use Junction Object to connect the two objects
A Junction Object is a custom object with two Master Detail relationships
Look up Master Detail
Parent is not required field Parent is required field
No impact on security and sharing Inherits parent security and sharing
No cascade delete Cascade Delete
25 relationships are possible Only 2 per object
Explain Record Types?
Force.com Programming Best Practices
Apex
Since Apex is case insensitive you can write it however youd like. However, to
increase
91

readability, follow Java capitalization standards and use two spaces instead of
tabs for indentation.
Use Asychronous Apex (@future annotation) for logic that does not need to be
executed
synchronous.
Asychronous Apex should be bulkified.
Apex code must provide proper exception handling.
Prevent SOQL and SOSL injection attacks by using static queries, binding
variables or the
escapeSingleQuotes method.
When querying large data sets, use a SOQL for loop
Use SOSL over SOQL where possible its much faster.
Use Apex Limits Methods to avoid hitting governor exceptions.
No SOQL or SOSL queries inside loops
No DML statements inside loops
No Async (@future) methods inside loops
Do not use hardcoded IDs
Triggers
There should only be one trigger for each object.
Avoid complex logic in triggers. To simplify testing and resuse, triggers should
delegate to Apex
classes which contain the actual execution logic. See Mike Leachs excellent trigger
template for
more info.
Bulkify any helper classes and/or methods.
Trigers should be bulkified and be able to process up to 200 records for each
call.
Execute DML statements using collections instead of individual records per DML
statement.
Use Collections in SOQL WHERE clauses to retrieve all records back in single
query
Use a consistent naming convention including the object name (e.g.,
AccountTrigger)
Visualforce
Do not hardcode picklists in Visualforce pages; include them in the controller
instead.
Javascript and CSS should be included as Static Resources allowing the browser
to cache them.
Reference CSS at the top and JavaScript at the bottom of Visualforce pages as this
provides for
faster page loads.
Mark controller variables as transient if they are not needed between server
92

calls. This will make


your page load faster as it reduces the size of the View State.
Use <apex:repeat> to iterate over large collections.
Use the cache attribute with the <apex:page> component to take advantage CDN
caching when
appropriate
Unit Testing
Use a consistent naming convention including Test and the name of the class
being tested (e.g.,
Test_AccountTrigger)
Test classes should use the @isTest annotation
Test methods should craete all data needed for the method and not rely on data
currently in the
Org.
Use System.assert liberally to prove that code behaves as expected.
Test each branch of conditional logic
Write test methods that both pass and fail for certain conditions and test for
boundary conditions.
Test triggers to process 200 records make sure your code is bulkified for 200
records and
doesnt throw the dreaded Too many SOQL queries: 21 exception.
When testing for governor limits, use Test.startTest and Test.stopTest and the
Limit class instead
of hard-coding governor limits.
Use System.runAs() to execute code as a specific user to test for sharing rules (but
not CRUD or
FLS permissions)
Execute tests with the Force.com IDE and not the salesforce.com UI. Weve seen
misleading
code coverage results when running from the salesforce.com UI.
Run the Force.com Security Source Scanner to test your Org for a number of
security and code
quality issues (e.g., Cross Site Scripting, Access Control Issues, Frame Spoofing)
If you have excess data from external site, how SOAP handles?
If you refresh sandbox, do you need to reset the oAuth?
If you change any objects or fields what happens to web services?
Action Support and Action Polor
What is the difference between standard controller and Standardset Controller?
Can you write a before Undelete trigger?
What are the Standard Fields created by SalesForce for a new Object?
ID
Owner
93

Name
Created by
Created DateTime
LastModified By
Last Modified DateTime
What are the Audit Fields in SalesForce?
Meaning of Audit Fields is To track all changes for a Record:
Created By
Created DateTime
LastModified By
Last Modified DateTime
What are the System Fields in SalesForce?
ID
Created By
Created DateTime
LastModified By
Last Modified DateTime
Week-1
1. The difference between Lead and the opportunity?
Leads are people who attend our campaigns to provide some
feedback/suggestions where the
opportunities are the ones who have been selected after the filter.. once we finalize
that who
will
be interested and who will be not then we will offer some discounts of our products
or provide
some more additional information about the products only for the filtered
Leads(opportunities).
Leads are window shoppers where as opportunities are interested people.
2. Through Sales force Import wizard how many records we can
import into
salesforce Objects and the wizard will support for which Objects?
Using Import wizard, we can upload up to 50,000 records.Only Accounts &
Contacts, Leads
and Solutions and custom objects data can be imported. If we want to import
other objects
like Opportunities and other objects data, then we need to go for Apex Data
Loader.
3. What is App in Sales force?
An app is a group of tabs that work as a unit to provide functionality. Users can
94

switch
between apps using the Force.com app drop-down menu at the top-right corner
of every page.
You can customize existing apps to match the way you work, or build new apps by
grouping
standard and custom tabs.
Navigation to create app in Sales force: Setup ->Build ->Create->App->
Click on
new and create your application according to your requirements.
4.What is object in Sales force?
Custom objects are database tables that allow you to store data specific to your
organization in
salesforce.com. You can use custom objects to extend salesforce.com functionality
or to build
new application functionality.
Once you have created a custom object, you can create a custom tab, custom
related lists,
reports, and dashboards for users to interact with the custom object data. You can
also access
custom object data through the Force.com API.
Navigation to create object in sales force: Setup->Build->Create->Object->
Click on
new object and create object according to your requirement.
5. Can you name some of the standard objects and define their
purposes?
Accounts: are your organizations customers, competitors, and partners. Each
account stores
information such as name, address, and phone numbers.
Contacts: are the people that your company will have or already has an on-going
relationship. A contact, which is an individual associated with an Account.
Cases: A customer issue such as a customers feedback, problem, or question.
Solutions: A detailed description of a customer issue and the resolution of that
issue.
6. Differences between custom objects and standard objects?
Objects already created for you by Salesforce are called standard objects. Objects
you create in
your organization are called custom objects.
7. What is the difference between public cloud and private cloud? Is
salesforce.com is a public cloud or private cloud?
Public Cloud: Could services are provided as a service over the Internet with
little or no
control over the underlying technology infrastructure. More than one tenant can
95

use the same


resources.
Private Cloud: This also offers activities and functions as a service but is
deployed over a
company intranet or hosted datacenter. This is private product for a company or
organization
offering advance security.
Salesforce.com: Is a public cloud as it is hosted on salesforce.com data centers
and data of
more than one tenant resides on same servers.
8.What is Standard and Custom Fields in Salesforce?
Standard Fields
What is a Standard Field?
Standard Fields are pre-defined in Salesforce
You cannot delete standard fields but you can remove non-required standard
fields from a
page layout
Standard Field customizations include the ability to change standard field labels
and tabs
You can change the display labels of standard tabs, objects, fields, and other
related
user interface labels so they better reflect your organizations business
requirements.
Renamed labels for example, Accounts changed to Companies display
on all
user pages, in Outlook Edition, and in Offline Edition.
Its important to note that all pages in the Setup area use the default, original
labels.
Reports and views are not renamed based on the new label value.
Custom Fields
What is a Custom Field?
Capture information unique to your business process by creating custom fields
with custom
field.
Recycle Bin for Deleted Custom Fields
Custom fields are deleted permanently after 15 days.
9. Is it possible to change the existing data types of custom fields, if Yes
please
explanin?
Yes. Its possible but Changing the data type of an existing custom field can cause
data loss in
the following situations:
96

Changing to or from type Date or Date/Time


Changing to Number from any other type
Changing to Percent from any other type
Changing to Currency from any other type
Changing from Checkbox to any other type
Changing from Picklist (Multi-Select) to any other type
Changing to Picklist (Multi-Select) from any type except Picklist
Changing from Auto Number to any other type
Changing to Auto Number from any type except Text
Changing from Text Area (Long) to any type except Email, Phone, Text, Text
Area, or
URL
10. What is a dependent picklist?
Dependent fields can help make your data more accurate and consistent by
applying filters.
A dependent field works in conjunction with a controlling field to filter its values.
The value
chosen in the controlling field affects the values available in the dependent field.
300 is the maximum number of values allowed in a controlling picklist
- A custom multi-select picklist cannot be the controlling field for a dependent
field
Field Type Controlling Field Dependent Field
Standard Picklist Yes No
Custom Picklist Yes Yes
Custom MultiSelect
No Yes
Standard
Checkbox
Yes No
Custom Checkbox Yes No
11. What the Salesforce System Fields?
The following fields are read-only fields found on most objects. These fields are
automatically
updated during API operations.
System Fields:
Id - Globally unique string that identifies a record. For information on IDs, see
ID Field
Type. Because this field exists in every object, it is not listed in the field table for
each
object. Id fields have Defaulted on create and Filter access.
IsDeleted - Indicates whether the record has been moved to the Recycle Bin
97

(true) or not
(false). Because this field does not appear in all objects, it is listed in the field table
for each
object.
Audit Fields
CreatedById- ID of the User who created this record. CreatedById fields have
Defaulted on
create and Filter access.
CreatedDate- Date and time when this record was created. CreatedDate fields
have
Defaulted on create and Filter access.
LastModifiedById- ID of the User who last updated this record.
LastModifiedById fields
have Defaulted on create and Filter access.
LastModifiedDate- Date and time when this record was last modified by a user.
LastModifiedDate fields have Defaulted on create and Filter access.
SystemModstamp - Date and time when this record was last modified by a user
or by an
automated process (such as a trigger). SystemModstamp fields have Defaulted on
create
and Filter access.
12. What are the differences between System Mod Stamp and Last
Modified
Date?
System Mod Stamp and Last Modified Date are approximately same everytime.
You will find
same value for both the fields, however, there are few examples when they might
differ.
Example :
If any organization's business requirement is to move all the data/records which
already exist
in one org, to another, they will require to keep the created and last modified date
same as
when the record was actually created or modified in the original org and not when
the data
was moved in the new org.
In this case, Salesforce provides an option to modify the Last Modified date and
keep it in
sync with your original records creation or modified date.
System Mod Stamp in this case will change to the new date when the data/record
was
uploaded in new org, however, Last Modified date can manually be changed to the
98

original
date when the records were modified in old org.
13. What are the differences between soft delete & Hard delete in
salesforce?
Hard Delete Vs Soft Delete:
Deleted Records:
The Recycle Bin link in the sidebar lets you view and restore recently deleted
records for 15
days before they are permanently deleted. If your organization reaches its
Recycle Bin limit,
Salesforce automatically removes the oldest records if they have been in the
Recycle Bin for at
least two hours. Your organization can have up to 5,000 records per license in
the Recycle
Bin
at any one time. For example, if your organization has five user licenses, 25,000
records can
be stored in the Recycle Bin.
Deleted Fields:
Deleted custom fields and their data are stored until your organization
permanently deletes
them or 15 days has elapsed, whichever happens first. Until that time, you can
restore the
field
and its data. However, the field still counts against the maximum number of
custom fields
allowed in your organization.
Standard fields can not be deleted ONLY customer fields of standard
or custom
object
can be deleted.
Deleted Objects:
When you delete a custom object, Salesforce does not add it to the Recycle Bin.
Instead,
deleted objects appear in the Deleted Objects list for 15 days. During this time, the
object
and its data are soft deleted, meaning you can restore or permanently erase (hard
delete)
the object and its data. After 15 days, the object and its data are automatically
hard
deleted.
14. What is schema builder? Can we create objects & relationships
99

using schema
builder?
Schema Builder provides a dynamic environment to add new custom objects,
custom
fields, and relationships to your schema. This eliminates the need to click from
page to
page to find the details of a master-detail relationship or to add a new custom field
to an
object in your schema. For example, if youre using Schema Builder to view the
details of
your schema, you can add a new custom object without leaving Schema Builder.
The draganddrop
interface lets you easily add a custom object or new field, and saves the layout of
your schema any time you move an object.
Schema Builder provides details such as the field values, required fields, and how
objects
are related by displaying lookup and master-detail relationships. You can view the
details
for both standard and custom objects in Schema Builder.
Schema Builder is enabled by default and lets you add the following to
your
schema:
Custom objects
Lookup relationships
Master-detail relationships
15. What do you mean by Hierarchical Relationship and explain?
Hierarchical Relationship allows users to click a lookup icon and select another
user from a
popup list.
Its exactly like a Lookup relationship, except the only things that are "special"
about
this type of relationship are:
It's only available on the User object where Lookup or Master/Detail are not.
It can only look up to the User object.
Type of relationship are easy ways to get:
- a user's complete upstream hierarchy (List)
- a user's complete downstream hierarchy (tree structure and/or Set)
- Determine if a user is in another user's upstream and distance
Determine if a user is in another user's downstream and distance
Wrapper Classes:
100

In the Visualforce community boards one of the most commonly asked questions
is, "How can I display a table of records with a check box and then process only
the records that are selected?", like this:

Wrapper class example:


This is a perfect scenario where a wrapper class can be used. Most of my
instructions and comments are in the code but anyone should feel free to modify
this entry to make it easier to understand.
First the Controller:
public class wrapperClassController {
//Our collection of the class/wrapper objects cContact
public List<cContact> contactList {get; set;}

//This method uses a simple SOQL query to return a List of Contacts


public List<cContact> getContacts() {
if(contactList == null) {
contactList = new List<cContact>();
for(Contact c: [select Id, Name, Email, Phone from Contact limit 10])

// As each contact is processed we create a new cContact object and


add it to the contactList
contactList.add(new cContact(c));
}
}
101

return contactList;
}
public PageReference processSelected() {
//We create a new list of Contacts that we be populated only with
Contacts if they are selected
List<Contact> selectedContacts = new List<Contact>();
//We will cycle through our list of cContacts and will check to see if the
selected property is set to true, if it is we add the Contact to the selectedContacts
list
for(cContact cCon: getContacts()) {
if(cCon.selected == true) {
selectedContacts.add(cCon.con);
}
}
// Now we have our list of selected contacts and can perform any type
of logic we want, sending emails, updating a field on the Contact, etc
System.debug('These are the selected Contacts...');
for(Contact con: selectedContacts) {
system.debug(con);
}
contactList=null; // we need this line if we performed a write operation
because getContacts gets a fresh list now
return null;
}
// This is our wrapper/container class. A container class is a class, a data
structure, or an abstract data type whose instances are collections of other objects.
In this example a wrapper class contains both the standard salesforce object
Contact and a Boolean value
public class cContact {
public Contact con {get; set;}
public Boolean selected {get; set;}
//This is the contructor method. When we create a new cContact object
we pass a Contact that is set to the con property. We also set the selected value to
false
102

public cContact(Contact c) {
con = c;
selected = false;
}
}

And then the Page:


<apex:page controller="wrapperClassController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton
value="Process
Selected"
action="{!processSelected}" rerender="table"/>
</apex:pageBlockButtons>
<!-- In our table we are displaying the cContact records -->
<apex:pageBlockTable value="{!contacts}" var="c" id="table">
<apex:column >
<!-- This is our selected Boolean property in our wrapper class ->
<apex:inputCheckbox value="{!c.selected}"/>
</apex:column>
<!-- This is how we access the contact values within our cContact
container/wrapper -->
<apex:column value="{!c.con.Name}" />
<apex:column value="{!c.con.Email}" />
<apex:column value="{!c.con.Phone}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

103

104

1. The difference between Lead and the opportunity?


Leads are people who attend our campaigns to provide some
feedback/suggestions where the opportunities are the ones who have been
selected after the filter.. once we finalize that who will be interested and who
will be not then we will offer some discounts of our products or provide
some more additional information about the products only for the filtered
Leads(opportunities).
Leads are window shoppers where as opportunities are interested people.

2. What is Apex

It is the in-house technology of salesforce.com which is similar to Java


programming with object oriented concepts and to write our own custom
logic.
3.
Is it possible to write the Apex code from user Interface?
You can add, edit, or delete Apex using the Salesforce.com user interface
only in a Developer Edition organization, a Salesforce.com Enterprise
Edition trial organization, or sandbox organization. In a Salesforce.com
production organization, you can only make changes to Apex by using the
Metadata API ,deploy call, the Force.com IDE, or theForce.com Migration
Tool.
The Force.com IDE and Force.com Migration Tool are free resources
provided by salesforce.com to support its users and partners, but are not
considered part of our Services for purposes of the salesforce.com Master
Subscription Agreement.
4. In How many ways we can invoke the Apex class?
a. Triggers

b. Web Services
c. Email Services
d. Batch Classes
e. Schedulable Classes
f. Test Class
g. Controller Classes for Visualforce pages
5. What is a class and explain in detail?
Apex classes are similar to Java classes.
105

A class is a template or blueprint from which Apex objects are created.


Classes consist of other classes, user-defined methods, variables, exception
types, and static initialization code. They are stored in the application under
Setup, in Develop | Apex Classes.
An Apex class can contain variables and methods.
Variables are used to specify the state of an object, such as the object's name
or type. Since these variables are associated with a class and are members
of it, they are referred to as member variables.
Methods are used to control behavior, such as purchasing or selling an item.
Methods can also contain local variables that are declared inside the
method and used only by the method. Whereas class member variables
define the attributes of an object, such as name or height, local variables in
methods are used only by the method and dont describe the class.
6. What are Access Modifiers in SalesForce?
Apex allows
using
the private, protected, public,
modifiers when defining methods and variables.

and global access

private
This is the default, and means that the method or variable is accessible only
within the Apex class in which it is defined. If we do not specify an access
modifier, the method or variable is private.
protected
This means that the method or variable is visible to any inner classes in the
defining Apex class. We can only use this access modifier for instance
methods and member variables. Note that it is strictly more permissive than
the default (private) setting, just like Java.
public
This means the method or variable can be used by any Apex in this
application or namespace.
global
This means the method or variable can be used by any Apex code that has
access to the class, not just the Apex code in the same application. This
access modifier should be used for any method that needs to be referenced
outside of the application, either in the SOAP API or by other Apexcode. If
we declare a method or variable as global, we must also declare the class
that contains it as global.
7. What is an Object?

106

object is an instance of a class. For example, a Fridge class describes the


state of a fridge and everything we can do with it. An instance of the Fridge
class is a specific refrigerator that can be purchased or sold.
8. How do you instantiate a Class?
ClassName objS = New ClassName();
9. What is an Instance Method?
Instance methods and member variables are used by an instance of a class,
that is, by an object. Instance member variables are declared inside a class,
but not within a method. Instance methods usually use instance member
variables to affect the behavior of the method.
instance methods and variables, which means you have to first create an
instance of the class to use. Each individual instance has its own copy of
instance variables, and the instance methods can access these variables.
10.
What is a Static Method?
Static methods are methods declared with the static keyword. Theyre
generally useful as utility methods and never depend on a particular
instance member variable value. Because you can only associate a static
method with a class, the static method cannot access any instance member
variable values of the class. Static variables are only static within the
scope of the request. They are not static across the server, or across the
entire organization.
When you need to have a member variable whose value is available to all
instances need to create a static variable. Static variables are associated with
the class and not the instance and you can access them without instantiating
the class.
11. What

is

the

scope

of

static

variable?

When you declare a method or variable as static, its initialized only once
when a class is loaded. Static variables arent transmitted as part of the view
state for a Visualforce page.
Static variables are only static within the scope of the request. They are not
static across the server, or across the entire organization.
12.What are the Keywords in SalesForce?
Apex has the following keywords available:
final
instanceof
107

super
this
transient
with sharing and without sharing
13. Explain with sharing and without sharing key words?
Apex generally runs in system context; that is, the current user's
permissions, field-level security, and sharing rules arent taken into account
during code execution.
Because these rules aren't enforced, developers who use Apex must take
care that they don't inadvertently expose sensitive data that would normally
be hidden from users by user permissions, field-level security, or
organization-wide defaults. They should be particularly careful with Web
services, which can be restricted by permissions, but execute in system
context once they are initiated.
Use the with sharing keywords when declaring a class to enforce the sharing
rules that apply to the current user.
14.What is an Interface?
An interface is a named set of method signatures (the return and parameter
definitions), but without any implementation.
Interfaces provide a layer of abstraction to your code. They separate the
specific implementation of a method from the declaration for that method.
This way, you can have different implementations of a method based on
your specific application.
15. What is a Sub class?
Apex supports subclasses, allowing you to create a class that extends
another class. The subclass inherits all the functionality of that parent class.
It can also have additional methods and member variables, and can override
the behavior of existing parent class methods.
16.What are Primitive Data Types in APEX Language?
Apex has a number of primitive data types. These are used to store data at
run time.
String: Strings are set of characters and are enclosed in single quotes. They
store text values such as a name or an address.
Integer, Long, Double and Decimal: Variables declared with any of
these data types hold numeric values.
108

Time, Date and Datetime: Variables declared with any of these data
types hold time, date, or time and date values combined
Boolean: Boolean values hold true or false values and you can use them to
test whether a certain condition is true or false
17. What is ID data type?
The ID data type represents an 18-character an object identifier. Force.com
sets an ID to a object once it is inserted into the database. For example, an
ID value can be a02D0000006YLCyIAO.
18.
What are Collection Objects?
Apex has the following types of collections:
Lists
Maps
Sets
A list is a collection of elements, such as Integers, Strings, objects, or other
collections.
List holds an ordered collection of objects.
Use a list when the sequence of elements is important. List can have
duplicate elements .
The index position of the first element in a list is always 0.
A set is an unordered collection of elements that do not contain any
duplicates. Set elements can be of any data typeprimitive types,
collections, sObjects, user-defined types, and built-in Apex types.
Apex uses a hash structure for all sets.
A set is an unordered collection. Do not rely on the order in which set results
are returned. The order of objects returned by sets may change without
warning.
A map is a collection of key-value pairs where each unique key maps to a
single value. Keys and values can be any data typeprimitive types,
collections, sObjects, user-defined types, and built-in Apex types.
19.What is a SObject?
sObject is a generic abstract type that corresponds to any persisted object
type. The generic sObject can be cast into a specific sObject type, such as an
account
An sObject is any object that can be stored in the Force.com platform
database. These are not objects in the sense of instances of Apex classes;
rather, they are representations of data that has or will be persisted.
sObject s = new Account();
109

20.
What are different DML Methods in SalesForce?
Data Manipulation Language (DML) methods help to perform different
data base transactions/operations.
SalesForce supports DML Statements like insert, update, delete, undelete.
This is called APEX DML Statements
Alternatively, SalesForce supports Database DML Statements. we can
perform DML operations by calling the methods provided by the Database
class.
Database.insert
Database.delete
21. What is the difference between database.insert and insert ?

insert is the DML statement which is same as databse.insert. However,


database.insert gives more flexibility like rollback, default assignment rules
etc. we can achieve the database.insert behavior in insert by using the
method
setOptions(Database.DMLOptions)
Important Difference:
If we use the DML statement (insert), then in bulk operation if error
occurs, the execution will stop and Apex code throws an error which can
be handled in try catch block.
If DML database methods (Database.insert) used, then if error occurs
the remaining records will be inserted / updated means partial DML
operation will be done.
22.
Rolling Back Transactions and Savepoints
Apex supports rolling back transactions. You can generate a savepoint
which sets a point in the request that corresponds to a state in the database.
Any DML statement that occurs after the savepoint can be discarded and
the database can be restored to the same initial condition.

23.

Locking Statements

110

Apex allows you to lock an sObject record to prevent other code from
making changes to it. Use the FOR UPDATE SOQL statement to lock a
record.
24.
What is an Exception?
Exceptions note errors and other events that disrupt the normal flow of
code execution. Throw statements are used to generate exceptions, while
try, catch, and finally statements are used to gracefully recover from
exceptions.
The advantage of using exceptions is that they simplify error handling.
Exceptions bubble up from the called method to the caller, as many levels
as necessary, until a catch statement is found that will handle the error.
using finally statements, we have one place to recover from exceptions, like
resetting variables and deleting data.
When an exception occurs, code execution halts and any DML operations
that were processed prior to the exception are rolled back and arent
committed to the database. Exceptions get logged in debug logs. For
unhandled exceptions, that is, exceptions that the code doesnt catch,
Salesforce sends an email to the developer with the organization ID and user
ID of the running
user, as well as the exception message.
If you run into an exception that occurred in Apex code while using the
standard user interface, an error message appears on the page showing you
the text of the unhandled exception
25.
Explain Try, Catch and
Finally Statements in SalesForce?
Apex uses try, catch and finally statements to handle exceptions.
The try statement identifies a block of code in which an exception can occur.
If you have code that you think could generate an exception, wrap this
section of your code in a try block, and add a catch block after it. Only
exceptions thrown from the code wrapped in the try block are handled by
the catch block.
The catch statement identifies a block of code that handles a particular type
of exception. In the previous example, notice that there are two catch
statements. You can have as many catch statements as you like, one for each
exception type you want to catch.

111

The finally statement is optional and gets executed after the catch block
executes. Code in the finally block always executes regardless of the type of
exception that was thrown and handled. You can add any final clean up code
here.
26.
Exceptions?
DML Exception
List Exception
NullPointerException
QueryException
SObjectException

Explain some Built In

27.
How to create Custom
Exception?
To create custom exception class, extend the built-in Exception class and
make sure class name ends with the word Exception. Append extends
Exception after class declaration
public class MyException extends Exception {}
28. What are different annotations in SalesForce?

An Apex annotation modifies the way a method or class is used, similar to


annotations in Java.
Annotations are defined with an initial @ symbol, followed by the
appropriate keyword. To add an annotation to a method, specify it
immediately before the method or class definition. For example:
global class MyClass {
@future
Public static void myMethod(String a)
{
//long-running Apex code
}
}
Apex supports the following annotations:
@Deprecated
112

@Future
@IsTest
@ReadOnly
@RemoteAction
@TestVisible
Apex REST annotations:
@RestResource(urlMapping='/yourUrl')
@HttpDelete
@HttpGet
@HttpPatch
@HttpPost
@HttpPut
29.

What is a Test Class in SalesForce?

To facilitate the development of robust, error-free code, Apex supports the


creation and execution of unit tests. Unit tests are class methods that verify
whether a particular piece of code is working properly.
Unit test methods take no arguments, commit no data to the database, send
no emails, and are flagged with the testMethod keyword or
the isTest annotation in the method definition.
Classes defined with the isTest annotation don't count against your
organization limit of 3 MB for all Apex code.
At least 75% of your Apex code must be covered by unit tests
Also, test methods must be defined in test classes, that is, classes annotated
with isTest.
@isTest
private class myClass {
113

static testMethod void myTest() {


code_block
}
}
@isTest
private class myClass {
@isTest static testMethod void myTest() {
code_block
}
}
Test methods cant be used to test Web service callouts. Instead, use mock
callouts. See Testing Web Service Callouts and Testing HTTP Callouts.
We cant send email messages from a test method.
Since test methods dont commit data created in the test, we dont have to
delete test data upon completion.
30. Explain

System.runAs()

Generally, all Apex code runs in system mode, and the permissions and
record sharing of the current user are not taken into account. The system
method, System.runAs(), lets you write test methods that change user
contexts to either an existing user or a new user. All of that users record
sharing is then enforced. You can only use runAs in a test method.
The original system context is started again after all runAs() test methods
complete.
Example :
1
2
3
4
5

System.runAs(u) {
// The following code runs as user 'u'
System.debug('Current User: ' + UserInfo.getUserName());
System.debug('Current Profile: ' + UserInfo.getProfileId());
// Run some code that checks record sharing
}

114

31.What are Apex Governor Limits?


Governor limits are runtime limits enforced by the Apex runtime engine.
Because Apex runs in a shared, multitenant environment, the Apex runtime
engine strictly enforces a number of limits to ensure that code does not
monopolize shared resources. Types of limits that Apex enforces are
resources like memory, database resources, number of script statements to
avoid infinite loops, and number of records being processed. If code exceeds
a limit, the associated governor issues a runtime exception.
32.
Do governor limits apply to sandbox instances?
Governor limits do apply to all Salesforce instances (trial, developer,
production or sandbox environments). However code coverage and
successful execution of test classes is only enforced when deploying to a
production environment.
33. In Which sequence Trigger and automation rules run in
Salesforce.com
The following is the order salesforce logic is applied to a record.
1. Old record loaded from database (or initialized for new inserts)
2. New record values overwrite old values
3. System Validation Rules
4. All Apex before triggers (EE / UE only)
5. Custom Validation Rules
6. Record saved to database (but not committed)
7. Record reloaded from database
8. All Apex after triggers (EE / UE only)
9. Assignment rules
10. Auto-response rules
11. Workflow rules
12. Escalation rules
115

13. Parent Rollup Summary Formula value updated (if present)


14. Database commit
15. Post-commit logic (sending email)
Additional notes: There is no way to control the order of execution
within each group above.
34.
If one object in Salesforce have 2 triggers which runs
before insert. Is there any way to control the sequence of
execution of these triggers?
Salesforce.com has documented that trigger sequence cannot be
predefined. As a best practice create one trigger per object and use
comment blocks to separate different logic blocks. By having all logic in one
trigger you may also be able to optimize on your SOQL queries.
35.

What is a Trigger?

Triggers are Apex code that execute before or after an insert, update, delete
or undelete event occurs on an sObject.
A trigger always starts with the trigger keyword, followed by the name of the
trigger, the database object to which the trigger should be attached to, and
then the conditions under which it should fire
trigger triggerName on ObjectName (trigger_events) {
code_block
}
The events you can specify are:
before insert
before update
before delete
after insert
after update
after delete
after undelete
36.
What is the difference between trigger.new and trigger.old
in Apex SFDC?
116

Trigger.new :
Returns a list of the new versions of the sObject records.
Note that this sObject list is only available in insert and update triggers,
and the records can only be modified in before triggers.
Trigger.old :
Returns a list of the old versions of the sObject records.
Note that this sObject list is only available in update and delete triggers.
37. How to restrict any Trigger to fire only once?

Or What is

Recursive Triggers?
You want to write a trigger that creates a new record as part of its processing
logic; however, that record may then cause another trigger to fire, which in
turn causes another to fire, and so on. You don't know how to stop that
recursion.
The before and after triggers fire one more time only if something needs to be
updated. If the fields have already been set to a value, the triggers are not fired
again.
Workaround:
Create a Helper Class, with a static Boolean variable.
Check its value within the affected triggers.
After the trigger is executed , set the Boolean to True.
38. In class declaration if we dont write keyword with sharing
then it runs in system mode then why keyword without sharing
is
introduced
in
apex?
Lets take example, there is classA declared using with sharing and it
calls classB method. classB is not declared with any keyword then by
default with sharing will be applied to that class because originating call
is done through classA. To avoid this we have to explicitly define classB with
keyword without sharing.
39. What

is

Scheduler

class

in

Apex?

The Apex class which is programmed to run at pre defined interval.


Class must implement schedulable interface and it contains method
117

named
execute().
There are two ways to invoke scheduler :
1. Using UI
2. Using System.schedule
The class which implements interface schedulable get the button texted with
Schedule, when user clicks on that button, new interface opens to schedule
the
classes
which
implements
that
interface.
To see what happened to scheduled job, go to Monitoring | Scheduled
jobs
40.
What is difference in ISNULL and ISBLANK?
ISNULL:
Determines if an expression is null (blank) and returns TRUE if it is.
If it contains a value, this function returns FALSE.
Text fields are never null, so using this function with a text field always
returns false. For example, the formula field IF(ISNULL(new__c) 1, 0)
is always zero regardless of the value in the New field. For text fields, use
the ISBLANK function instead.
Multi-select picklist fields are never null in s-controls, buttons, and
email templates, so using this function with a multi-select picklist field
in those contexts always returns false.
Empty date and date/time fields always return true when referenced
in ISNULL functions.
Choose Treat blank fields as blanks for your formula when referencing
a number, percent, or currency field in an ISNULL function. Choosing
Treat blank fields as zeroes gives blank fields the value of zero so none of
them will be null.
Merge fields can be handled as blanks, which can affect the results of
components like s-controls because they can call this function.
When using a validation rule to ensure that a number field contains a
specific value, use the ISNULL function to include fields that do not
contain any value. For example, to validate that a custom field contains
a value of 1, use the following validation rule to display an error if the
field is blank or any other number: OR(ISNULL(field__c), field__c<>1)
118

ISBLANK:
Determines if an expression has a value and returns TRUE if it does
not. If it contains a value, this function returns FALSE.
Use ISBLANK instead of ISNULL in new formulas. ISBLANK has

the same functionality as ISNULL, but also supports text fields.


Salesforce.com will continue to support ISNULL, so you do not need to
change any existing formulas.
A field is not empty if it contains a character, blank space, or zero. For
example, a field that contains a space inserted with the spacebar is not
empty.
Use the BLANKVALUE function to return a specified string if the field
does not have a value; use the ISBLANK function if you only want to
check if the field has a value.
If you use this function with a numeric field, the function only returns
TRUE if the field has no value and is not configured to treat blank fields
as zeroes.
41. What

is

the

dynamic

Apex?

Dynamic Apex enables developers to create more flexible applications by


providing them with the ability to Access sObject and field describe
information, Write Dynamic SOQL Queries, Write Dynamic
SOSL Queries and Dynamic DML.
42.

What is a Visualforce Page ?


Visualforce is the new markup language from salesforce, by using which,
We can render the standard styles of salesforce. We can still use HTML here
in Visualforce. Each visualforce tag always begins with apex namespace.
All the design part can be accomplished by using Visualforce Markup
Language and the business logic can be written in custom controllers
associated with the Page

43. Where

to

write

Visualforce

You can write the code basically in 3 ways.


119

code

1. setup->App Setup->Develop->Pages and create new Visulaforce page.


2. Setup -> My Personal Information -> Personal Information -> Edit
checks the checkbox development mode. When you run the page like this,
https://ap1.salesforce.com/apex/MyTestPage. you will find the Page
editor at the bottom of the page. You can write you page as well as the
controller class associated with it, there it self.
3. Using EclipseIDE you can create the Visulaforce page and write the code.
44.
Explain the MVC design pattern of Salesforce.com
Model view controller (MVC) design pattern is the one of the most popular
design pattern in 3 tier applications. 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. One normal questions asked in
salesforce is explaining the MVC behavior of the application.

So lets discuss that how Salesforce.com uses MVC pattern.


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
45. How to display error messages in the visualforce page ?

In Apex use below code to create the error message for visualforce.
1
120

Apexpages.addMessage(
new
ApexPages.Message
(ApexPages.Severity.ERROR,'Required fields are missing. '));
in Visualforce page add below tag where you want to display the error
message.
<apex:pageMessages ></apex:pageMessages>
46. What

is

the

controller

extension?

Any apex class having a public constructor with Custom Controller or


Standard Controller object as a single argument is known as controller
extension.
47.
we

How many controllers can be used in a visual force page?


can use only two controller at a time in VF page.

One is standard controller and another one is Extended Controller.


48.

What is difference between component and controller?

Component is nothing but it type of Programming function, which we can


use to encapsulate common design patterns and then reuse those patterns
in one or more.
Controller.. this is a class used to derive you custom business functionality
49. Explain the need or importance of the controller extension.

Controller extension is very useful and important concept introduced by the


salesforce recently. It gives the power to programmer to extend the
functionality of existing custom controller or standard controller.
A Visualforce can have a single Custom controller or standard controller but
many
controller
extensions.
we can say that the custom extension is the supporter of custom or standard
controller.
Consider one example : If there is one controller written and used by the
multiple visualforce pages and one of them needs some extra logic. Then
instead of writing that logic to controller class (Which is used by many
visualforce pages) we can create a controller extension and apply to that
page only.
121

50. What

is
S-Control
?
Ans: S-Controls are the predominant salesforce.com widgets which are
completely based on Javascript. These are hosted by salesforce but executed
at client side. S-Controls are superseded by Visualforce now.

51. What is Difference in render, rerender and renderas attributes

of

visualforce?

render It works like display property of CSS. Used to show or hide


element.
rerender After Ajax which component should be refreshed available
on
commandlink,
commandbutton,
actionsupport
etc.
renderas render page as pdf, doc and excel.
52. What

are

the

types

of

controller

in

visual

force?

There are basically two types of Controller in Visual force page.


1. Standard Controller and
2. Custom Controller
53.

How many Controllers can be used on single VF page?


Only one controller can be used salesforce. Other than them, Controller
extension can be used. There may be more than one Controller
extension.
Example :
<apex:page
standardController="Account"
extensions="ExtOne,ExtTwo" showHeader="false">
<apex:outputText value="{!foo}" />
</apex:page>
if ExtOne and ExtTwo, both have the method getFoo() then the method
of ExtOne will be executed.
122

A controller extension is any Apex class that contains a constructor that


takes a single argument of typeApexPages.StandardController or
CustomControllerName, where CustomControllerName is the name
of a custom controller that you want to extend.
54.
What is the need of Custom Controller in Visualforce as
everything can be done by the combination of Standard
Controller
+
Extension
class.
a. Sharing setting is applied on standard object/extension by default; In
case we dont want to apply sharing setting in our code then Custom
controller is only option.
b. It is possible that the functionality of page does not required any
Standard object or may require more than one standard object, then
in that case Custom controller is required.
55.

How to implement the pagination in SOQL ?

In spring 12, Salesforce has come up with ability of SOQL to get records from
position X instead of position 1 every time to help creating pagination
feature
56.
Difference
between
Sandbox
and
Development
environment?
A test environment for salesforce.com is crucial to change control.
Salesforce.com provides the tools needed to test anything in a test
environment before you implement it in your live instance. You can either
test in a Sandbox environment or in a Developer environment. What is the
difference? I will share what I know
Sandbox
The salesforce.com Sandbox environment is an exact copy of your
salesforce.com instance. You can copy your live instance to a sandbox
environment (but you have to perform manually from sandbox to developer
edition) where you can test any changes, implementations, AppExchange
apps or updates. It can also be your hands-on training environment without
risking your live data.
You can either copy your configuration and data into a sandbox
environment or just the configuration. It acts exactly like your live instance,
123

but be careful if you have workflow rules or automations because they will
work in the sandbox as well.
I know that this sounds wonderful and if you dont have it, you are dying to
know how to get it. The problem is the cost. If you are on Unlimited Edition,
then cost is not a problem because it comes included. But for Enterprise,
Professional or Group Editions, you have to pay and the price is hefty;
anywhere between 25k-50k per year. For a lot of companies, that is more
than they are paying for their live salesforce.com instance. So how do you
test salesforce.com without Sandbox? It is always suggested to develop
application in sandbox instance then go for LIVE.
Developer Edition
Developer Edition was an edition created for development of integrations
and apps, specifically for the AppExchange. It is also a great tool for
testing/training in salesforce.com. What makes this a great tool is the fact
that it is free. Anyone can get a Developer Edition of salesforce.com. It is a
standard Enterprise Edition with very limited storage space. You cannot
copy your configuration or data onto the Developer Edition, but you can
customize it to match your instances look and feel. Once it is customized,
you can use it for training, testing or anything else you want. It takes a little
bit of work, but you can make it act and feel just like your live instance. The
work is well worth it for the free price.
57.
How to get the list of all available sobject in salesforce
database using Apex (Dynamic Apex)?
Map<String, Schema.SObjectType> m = Schema.getGlobalDescribe();
58.

How to create instance of sobject dynamically?

Normally the sobject is created like Account a = new Account();. But if


you are in situation that you dont know which sobject is going to be
instantiated ? Means it will be decided at runtime, how you will handle it?
Hint
:
Use
public SObject getNewSobject(String t){

Dynamic

// Call global describe to get the map of string to token.

124

Apex.

Map<String,
Schema.SObjectType>
Schema.getGlobalDescribe();

gd

// Get the token for the sobject based on the type.


Schema.SObjectType st = gd.get(t);
// Instantiate the sobject from the token.
Sobject s = st.newSobject();
return s;
}
59. How to get all the fields of sObject using dynamic Apex?

1 Map<String,
Schema.SObjectType>
Schema.getGlobalDescribe() ;

2 Schema.SObjectType s = m.get('API_Name_Of_SObject') ;

3 Schema.DescribeSObjectResult r = s.getDescribe() ;
4 Map<String,Schema.SObjectField> fields = r.fields.getMap() ;
60. How to get all the required fields of sObject dynamically?

There is no direct property available in Apex dynamic API to represent the


required field. However there is another way to know about it.
If any fields have below three properties then it is mandatory field.
1. If it is Creatable
2. If it is not nillable and
125

3. If it does not have any default value


61. How

to

get

the

picklist

value

in

Apex

class?

Using Dynamic apex, we can achieve this.on object of type pickilist, call
getDescribe(). then call thegetPicklistValues() method. iterate over
result and create a list. bind it to <apex:selectOptions>.
62. What

is

the

custom

settings?

Custom settings are similar to custom objects and enable application


developers to create custom sets of data, as well as create and associate
custom data for an organization, profile, or specific user. All custom settings
data is exposed in the application cache, which enables efficient access
without the cost of repeated queries to the database. This data can then be
used by formula fields, validation rules, Apex, and the Web services API.
63. Types

of

the

custom

settings?

List
Custom
Settings
A type of custom setting that provides a reusable set of static data that can
be accessed across your organization. If you use a particular set of data
frequently within your application, putting that data in a list custom setting
streamlines access to it. Data in list settings does not vary with
profile or user, but is available organization-wide. Examples of list
data include two-letter state abbreviations, international dialing prefixes,
and catalog numbers for products. Because the data is cached, access is lowcost and efficient: you dont have to use SOQL queries that count against
your governor limits.
Hierarchy
Custom
Settings
A type of custom setting that uses a built-in hierarchical logic that lets you
personalize settings for specific profiles or users. The hierarchy logic
checks the organization, profile, and user settings for the current user and
returns the most specific, or lowest, value. In the hierarchy, settings for an
organization are overridden by profile settings, which, in turn, are
overridden by user settings
64. Other than SOQL and SOSL what is other way to get custom
settings?
126

Other than SOQL or SOSL, Custom seting have their own set of methods to
access
the
record.
For example : if there is custom setting of name ISO_Country,
1
SO_Country__c code = ISO_Country__c.getInstance(INDIA);
2
//To return a map of data sets defined for the custom object (all
records in the custom object), //you would use:
3
Map<String,ISO_Country__c>
mapCodes
=
ISO_Country__c.getAll();
4
// display the ISO code for India
5
System.debug(ISO Code: +mapCodes.get(INDIA).ISO_Code__c);
6
//Alternatively you can return the map as a list:
7
List<String> listCodes = ISO_Country__c.getAll().values();
65.
What is a Callout?
Callouts enable Apex to invoke external web or HTTP services. Apex Web
services allow an external application to invoke Apex methods through Web
services.
Apex provides integration with Web services that utilize SOAP and WSDL,
or HTTP services (RESTful services).
66.

What is a Remote Site Setting?

Before any Apex callout can call an external site, that site must be registered
in the Remote Site Settings page, or the callout fails. Salesforceprevents
calls to unauthorized network addresses.
To add a remote site setting:
a. From Setup, click Security Controls | Remote
Settings.
b. Click New Remote Site.
c. Enter a descriptive term for the Remote Site Name.
d. Enter the URL for the remote site.
e. Optionally, enter a description of the site.
f. Click Save.

Site

67.
What is REST API?
Representational State Transfer (REST) is a style of software architecture
for distributed hypermedia systems such as the World Wide Web.
127

68. What is the default timeout period while calling webservice from

Apex.
10 sec.
69. A single Apex transaction can make how many callouts to an

HTTP
request
or
an
API
call?
Maximum 10 callouts
70. How to increase timeout while calling web service from Apex ?
docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.timeout_x = 2000; // timeout in milliseconds
71. How to force lead assignment rule via Apex while updating or

adding
the
Lead?
To enforce Assignment Rules in Apex you will need to perform following
steps:
1. Instantiate the Database.DMLOptions class.
2. Set the useDefaultRule property of assignmentRuleHeader to True.
3. Finally call a native method on your Lead called setOptions, with the
Database.DMLOptions instance as the argument.

72. How

to
convert
lead
using
Apex?
Lead myLead = new Lead(LastName = 'Foo', Company='Foo Bar');

insert myLead;

Database.LeadConvert lc = new database.LeadConvert();

lc.setLeadId(myLead.id);

7
LeadStatus convertStatus = [SELECT Id, MasterLabel FROM
LeadStatus WHERE IsConverted=true LIMIT 1];
8

lc.setConvertedStatus(convertStatus.MasterLabel);

10

Database.LeadConvertResult lcr = Database.convertLead(lc);

11

System.assert(lcr.isSuccess());

128

Application Security (Profile)

129

A profile contains user permissions and access settings that control what users
can do within their organization

Which standard and custom apps users can view

Which tabs users can view

Which record types are available to users

Which page layouts users see

Object permissions that allow users to create, read, edit, and delete
records

Which fields within objects users can view and edit

Permissions that allow users to manage the system and apps within it

Which Apex classes and Visualforce pages users can access

Which desktop clients users can access

The hours during which and IP addresses from which users can log in

Which service providers users can access (if Salesforce is enabled as


an identity provider)
In Contact Manager, Group, and Professional Edition organizations, you can
assign standard profiles to your users, but you can't view or edit the standard
profiles or create custom profiles. In Enterprise, Unlimited, and Developer
Edition organizations, you can use standard profiles, or create, edit, and delete
custom profiles. For standard profiles, only certain settings can be changed.
Each standard or custom profile belongs to exactly one user license type.

Record Level Security (Sharing)

130

Record-Level Security (Sharing)


Record-level security lets you give users access to some object records, but
not others. Every record is owned by a user or a queue. The owner has full
access to the record.

Organization Wide Defaults, Role Hierarchy, Sharing Rules,


Manual sharing Rules, Apex Managed Sharing Rules are different
settings in SalesForce to share the record with other users.
Organization Wide Defaults settingsThe first step in record-level
security is to determine the organization-wide sharing settings for each
object. Organization-wide sharing settings specify the default level of
access users have to each others records.
131

Private
Public Read Only
Public Read Write
You use organization-wide sharing settings to lock down your data to the
most restrictive level, and then use the other record-level security and
sharing tools to selectively give access to other users. For example, lets
say users have object-level permissions to read and edit opportunities,
and the organization-wide sharing setting is Read-Only. By default,
those users can read all opportunity records, but cant edit any unless
they own the record or are granted additional permissions.
Role hierarchyOnce youve specified organization-wide sharing
settings, the first way you can give wider access to records is with a role
hierarchy. Similar to an organization chart, a role hierarchy represents a
level of data access that a user or group of users needs. The role hierarchy
ensures that users higher in the hierarchy always have access to the same
data as people lower in their hierarchy, regardless of the organizationwide default settings. Role hierarchies dont have to match your
organization chart exactly. Instead, each role in the hierarchy should
represent a level of data access that a user or group of users needs.
You can also use a territory hierarchy to share access to records. A
territory hierarchy grants users access to records based on criteria such
as zip code, industry, revenue, or a custom field that is relevant to your
business. For example, you could create a territory hierarchy in which a
user with the North America role has access to different data than users
with the Canada and United States roles.
Note
Although its easy to confuse permission sets and profiles with roles, they
control two very different things. Permission sets and profiles control a
users object and field access permissions. Roles primarily control a
users record-level access through role hierarchy and sharing rules.
Sharing rulesSharing rules let you make automatic exceptions to
organization-wide sharing settings for particular sets of users, to give
them access to records they dont own or cant normally see. Sharing
rules, like role hierarchies, are only used to give additional users access
to recordsthey cant be stricter than your organization-wide default
settings.
Manual sharingSometimes its impossible to define a consistent
group of users who need access to a particular set of records. In those
situations, record owners can use manual sharing to give read and edit
permissions to users who would not have access to the record any other
way. Although manual sharing isnt automated like organization-wide
132

sharing settings, role hierarchies, or sharing rules, it gives record owners


the flexibility to share particular records with users that need to see them.
Apex managed sharingIf sharing rules and manual sharing dont
give you the control you need, you can use Apex managed sharing. Apex
managed sharing allows developers to programmatically share custom
objects. When you use Apex managed sharing to share a custom object,
only users with the Modify All Data permission can add or change the
sharing on the custom object's record, and the sharing access is
maintained across record owner changes.
Triggers and Order of Execution
When you save a record with an insert, update, or upsert statement, Salesforce
performs the following events in order.
Note
Before Salesforce executes these events on the server, the browser runs JavaScript
validation if the record contains any dependent picklist fields. The validation
limits each dependent picklist field to its available values. No other validation
occurs on the client side.
On the server, Salesforce:
1.
Loads the original record from the database or initializes the record
for an upsert statement.
2.
Loads the new record field values from the request and overwrites the
old values.
If the request came from a standard UI edit page, Salesforce runs system
validation to check the record for:
Compliance with layout-specific rules
Required values at the layout level and field-definition level
Valid field formats
Maximum field length
Salesforce doesn't perform system validation in this step when the request
comes from other sources, such as an Apex application or a SOAP API call.
1.
Executes all before triggers.
2.
Runs most system validation steps again, such as verifying that all
required fields have a non-null value, and runs any user-defined validation
rules. The only system validation that Salesforce doesn't run a second time
(when the request comes from a standard UI edit page) is the enforcement
of layout-specific rules.
3.
Saves the record to the database, but doesn't commit yet.
4.
Executes all after triggers.
133

5.
6.
7.
8.

Executes assignment rules.


Executes auto-response rules.
Executes workflow rules.
If there are workflow field updates, updates the record again.
9.
If the record was updated with workflow field updates, fires before and
after triggers one more time (and only one more time), in addition to
standard validations. Custom validation rules are not run again.
1.
Executes escalation rules.
2.
If the record contains a roll-up summary field or is part of a crossobject workflow, performs calculations and updates the roll-up summary
field in the parent record. Parent record goes through save procedure.
3.
If the parent record is updated, and a grand-parent record contains a
roll-up summary field or is part of a cross-object workflow, performs
calculations and updates the roll-up summary field in the parent record.
Grand-parent record goes through save procedure.
4.
Executes Criteria Based Sharing evaluation.
5.
Commits all DML operations to the database.
6.
Executes post-commit logic, such as sending email.

SalesForce Application Limits


Enterprise
Custom fields
500
Custom Relationships 25
Active Workflow Rules 50
Active Validation Rules 100
Approval Processes
500
Sharing
Rules 300
(Criteria-Based Only)
Custom Objects
200
Custom Tabs
25
Master
Detail 2
Relationships
Field History Tracking 20
Formula
3900 characters (4KB)
Web To Lead
500
134

Unlimited
800
25
50
300
500
300
2000
Unlimited
2
20
3900 characters (4KB)
500

Web to Case
Roles
Field Filters Per Report
Formulas Per Report

5000
500
20
5

5000
500
20
5

Pick List Limits


The maximum number of entries you can have in a picklist is determined by the
total number of characters allowed in the picklist, which is 15,000 characters.
Note that each entry includes a linebreak and a return character that are not
visible. These two additional characters per entry are counted as part of the
15,000 character limit.

Apex Governor Limits


Because Apex runs in a multitenant environment, the Apex runtime engine
strictly enforces a number of limits to ensure that runaway Apex does not
monopolize shared resources.
Description
Total number of SOQL queries issued
Total number of SOQL queries issued for Batch Apex and future
methods
Total number of records retrieved by SOQL queries
Total number of SOSL queries issued
Total number of records retrieved by a single SOSL query
Total number of DML statements issued2
135

Limit
100
200
50,000
20
200
150

Total number of records processed as a result of DML


statements, Approval.process, or database.emptyRecycleBin
Total number of executed code statements
Total number of executed code statements for Batch Apex and
future methods
Total heap size
Total heap size for Batch Apex and future methods
Total stack depth for any Apex invocation that recursively fires
triggers due to insert
update, or delete statements
For loop list batch size
Total number of callouts (HTTP requests or Web services calls)
in a request
Maximum timeout for all callouts (HTTP requests or Web
services calls) in a request
Default timeout of callouts (HTTP requests or Web services
calls) in a request
Total number of methods with the future annotation allowed
per Apex invocation
Maximum size of callout request or response (HTTP request or
Web services call)
Total number of sendEmail methods allowed
Total number of describes allowed7
Total number of classes that can be scheduled concurrently

10,000
200,000
1,000,000
6MB
12MB
16
30
200
10
120
seconds
10 seconds
10
3MB
10
100
25

Force.com Programming Best Practices


Apex
Since Apex is case insensitive you can write it however youd like. However,
to increase readability, follow Java capitalization standards and use two
spaces instead of tabs for indentation.
Use Asychronous Apex (@future annotation) for logic that does not need to
be executed synchronous.
Asychronous Apex should be bulkified.
Apex code must provide proper exception handling.

136

Prevent

SOQL and SOSL injection attacks by using static queries, binding


variables or the escapeSingleQuotes method.
When querying large data sets, use a SOQL for loop
Use SOSL over SOQL where possible its much faster.
Use Apex Limits Methods to avoid hitting governor exceptions.
No SOQL or SOSL queries inside loops
No DML statements inside loops
No Async (@future) methods inside loops
Do not use hardcoded IDs
Triggers
There should only be one trigger for each object.
Avoid complex logic in triggers. To simplify testing and resuse, triggers
should delegate to Apex classes which contain the actual execution logic. See
Mike Leachs excellent trigger template for more info.
Bulkify any helper classes and/or methods.
Trigers should be bulkified and be able to process up to 200 records for
each call.
Execute DML statements using collections instead of individual records per
DML statement.
Use Collections in SOQL WHERE clauses to retrieve all records back in
single query
Use a consistent naming convention including the object name (e.g.,
AccountTrigger)
Visualforce
Do not hardcode picklists in Visualforce pages; include them in the
controller instead.
Javascript and CSS should be included as Static Resources allowing the
browser to cache them.
Reference CSS at the top and JavaScript a the bottom of Visualforce pages
as this provides for faster page loads.
Mark controller variables as transient if they are not needed between
server calls. This will make your page load faster as it reduces the size of the
View State.
Use <apex:repeat> to iterate over large collections.
Use the cache attribute with the <apex:page> component to take advantage
CDN caching when appropriate
Unit Testing

137

Use

a consistent naming convention including Test and the name of the


class being tested (e.g., Test_AccountTrigger)
Test classes should use the @isTest annotation
Test methods should craete all data needed for the method and not rely on
data currently in the Org.
Use System.assert liberally to prove that code behaves as expected.
Test each branch of conditional logic
Write test methods that both pass and fail for certain conditions and test for
boundary conditions.
Test triggers to process 200 records make sure your code is bulkified for
200 records and doesnt throw the dreaded Too many SOQL queries: 21
exception.
When testing for governor limits, use Test.startTest and Test.stopTest and
the Limit class instead of hard-coding governor limits.
Use System.runAs() to execute code as a specific user to test for sharing
rules (but not CRUD or FLS permissions)
Execute tests with the Force.com IDE and not the salesforce.com UI. Weve
seen misleading code coverage results when running from the salesforce.com
UI.
Run the Force.com Security Source Scanner to test your Org for a number
of security and code quality issues (e.g., Cross Site Scripting, Access Control
Issues, Frame Spoofing)

Salesforce.com Interview Questions


1.
What
is
Apex
Ans: It is the in-house technology of salesforce.com which is similar to Java
programming with object oriented concepts and to write our own custom logic.
2.
What
is
S-Control
?
Ans: S-Controls are the predominant salesforce.com widgets which are
completely based on Javascript. These are hosted by salesforce but executed at
client side. S-Controls are superseded by Visualforce now.
138

3.
What
is
a
Visualforce
Page
?
Ans: Visualforce is the new markup language from salesforce, by using which, We
can render the standard styles of salesforce. We can still use HTML here in
Visualforce. Each visualforce tag always begins with apex namespace. All the
design part can be acomplished by using Visualforce Markup Language and the
business logic can be written in custom controllers associated with the Page.
4. Will Visual force still supports the merge fields usage like S-control ?
Ans: Yes. Just like S-Controls, Visualforce Pages support embedded merge fields,
like the {!$User.FirstName} used in the example.
5.
Where
to
write
Visualforce
Ans: You can write the code basically in 3 ways.

code

1. setup->App Setup->Develop->Pages and create new Visulaforce page.


2. Setup -> My Personal Information -> Personal Information -> Edit check
the checkbox development mode. When you run the page like this,
https://ap1.salesforce.com/apex/MyTestPage. you will find the Page editor
at the bottom of the page. You can write you page as well as the controller
class associated with it, there it self.
3. Using EclipseIDE you can create the Visulaforce page and write the code.

6.What
are
Apex
Governor
Limits?
Governor limits are runtime limits enforced by the Apex runtime engine. Because
Apex runs in a shared, multitenant environment, the Apex runtime engine strictly
enforces a number of limits to ensure that code does not monopolize shared
resources. Types of limits that Apex enforces are resources like memory, database
resources, number of script statements to avoid infinite loops, and number of
records being processed. If code exceeds a limit, the associated governor issues a
runtime
exception.

10. Do governor limits apply to sandbox instances?


Ans : Governor limits do apply to all Salesforce instances (trial, developer,
production or sandbox environments). However code coverage and successful
execution of test classes is only enforced when deploying to a production
environment.
139

for further study you can read this link.


12. Is it possible to write the Apex code from user Interface?
You can add, edit, or delete Apex using the Salesforce.com user interface only in
a Developer Edition organization, a Salesforce.com Enterprise Edition trial
organization,
or sandboxorganization.
In
a Salesforce.com production
organization, you can only make changes to Apex by using the Metadata API ,
deploycall, the Force.com IDE, or theForce.com Migration Tool. The Force.com
IDE and Force.com
Migration
Tool are
free
resources
provided
by salesforce.com to support its users and partners, but are not considered part of
our Services for purposes of the salesforce.com Master Subscription Agreement.
13. When you cant add Time dependent action in Workflow rule?
You cant add time-dependent actions to a rule if you choose Every time a record
is created or edited.
For more study, check this article
14. What are the types of email templates available in salesforce.com?
1. Text
2. HTML with Letter Head
3. Custom HTML
4. Visual force
To study more on email templates, refer this article
15. What are the different Salesforce.com Editions and Limits?
Ans : check this URL
16. What is Roll up summary field in Salesforce?
Roll up summary field in salesforce calculates the Count, Sum, Min or Max of
particular field of any child record. Thus, we can say that Roll up summary field
can only be created on Master object. To read further, please check this URL
17. What will happen if the Account is deleted?
If the Account is deleted then Contact, Opportunity will also be deleted from
Salesforce which are related to that Account.
140

From the database perspective, check below image of child relationships of


Account:

Account Child relationship in salesforce


If we use schema builder, released in Winter 12 it would look like:

Account Contact and Opportunity of salesforce in schema builder


18. How many types of the relationship fields available in Salesforce>
Ans :
141

1. Master Detail
2. Many to Many
3. Lookup
4. Hierarchical
For further study read this.
19. How to create many to many relationships between object?
Creating many to many relationship in salesforce is little tricky. You cannot create
this type of relationship directly. Follow below steps to create this type of
relationship.
Create both objects which should be interlinked.
Create one custom object (also called as junction object), which should have
autonumber as unique identification and create two master relationships for
both objects, no need create tab for this object.
Now on both object, add this field as related list.
20. In Which sequence Trigger and automation rules run in
Salesforce.com The following is the order salesforce logic is applied to a record.
1. Old record loaded from database (or initialized for new inserts)
2. New record values overwrite old values
3. System Validation Rules
4. All Apex before triggers (EE / UE only)
5. Custom Validation Rules
6. Record saved to database (but not committed)
7. Record reloaded from database
8. All Apex after triggers (EE / UE only)
9. Assignment rules
10.
Auto-response rules
11.
Workflow rules
12.
Escalation rules
13.
Parent Rollup Summary Formula value updated (if present)
14.
Database commit
15.
Post-commit logic (sending email)
Additional notes: There is no
execution within each group above.

way

to control

the

order

of

21. If one object in Salesforce have 2 triggers which runs before


insert. Is there any way to control the sequence of execution of these
triggers?
142

Ans : Salesforce.com has documented that trigger sequence cannot be


predefined. As a best practice create one trigger per object and use comment
blocks to separate different logic blocks. By having all logic in one trigger you may
also be able to optimize on your SOQL queries.
22.
How
to
delete
the
User
from
Salesforce?
Ans : As per now, salesforce does not allow to delete any user, however you can
deactivate
the
user.
Read further
23.
How
to
delete
the
users
data
from
Salesforce?
Ans : To delete the Users Data go to Setup | Administration Setup | Data
Management | Mass Delete Record, from there select the objects like Account,
Lead etc and in criteria select the users name and delete all records of that user
related to particular object.
24. How to restrict the user to see any record, lets say opportunity?
Ans : set up opportunity sharing to be private. If both users are admins or have
view all records on opportunity, then that overrides private sharing.
25. What is the difference between trigger.new and trigger.old in Apex

SFDC?
Ans
:
Trigger.new
:
Returns a list of the new versions of the sObject records.
Note that this sObject list is only available in insert and update triggers, and
the
records
can
only
be
modified
in before
triggers.
Trigger.old
:
Returns a list of the old versions of the sObject records.
Note that this sObject list is only available in update and delete
triggers.
26. How to restrict any Trigger to fire only once ?
Ans:
Triggers can fire twice, once before workflows and once after workflows, this is
documented
at
http://www.salesforce.com/us/developer/docs/apexcode/
Content/
143

apex_triggers_order_of_execution.htm:
The before and after triggers fire one more time only if something needs to be
updated. If the fields have already been set to a value, the triggers are not fired
again.
Workaround:
Add a static boolean variable to a class, and check its value within the affected
triggers.
1 public class HelperClass {
2 public static boolean firstRun = true;
3}
4 trigger affectedTrigger on Account (before delete, after delete, after undelete) {
5 if(Trigger.isBefore){
6
if(Trigger.isDelete){
7
if(HelperClass.firstRun){
8
Trigger.old[0].addError('Before Account Delete Error');
9
HelperClass.firstRun=false;
10
}
11
}
12 }
13 }

27. What is difference between WhoId and WhatId in the Data Model
of
Task
?
Ans
:
WhoID refers to people things. So that would be typically a Lead ID or a Contact
ID
WhatID refers to object type things. That would typically be an Account ID or an
Opportunity
ID
Check Data Model of task here
28. Where is the option of the report for the Custom Object with
related object and what are the condition to generate related reports?
Ans
:
If the parent object is the standard object provided by the salesforce like Account,
Contact then the report will be in there section with related custom object.
If both objects are the custom then the report will be in Other Reports
144

Sections.
Following are the conditions to get the report of related objects:
On both the objects, Reports option must be enable.
The relationship between both of them must be Master detail
relationship.
Read this article, to get detailed idea on this topic.
29. How you can provide the User Login (Authentication) in Public
sites
created
by
Salesforce.
Answer : We can provide the authentication on public sites using Customer
Portal.

Salesforce.com Interview Questions


What is Force.com and Salesfore.com? Mention the differences.
Force.com is a cloud computing platform where the developers build multitenant
applications.
Salesforce.com is also a cloud computing platform, it contains only standard
objects.
Salesforce.com
is
hoisted
on
Force.com.
What are the Force.com editions and salesfoce.com editions?
Force.com
includes
5
editions.
Free
edition
Enterprise
with
one
app
Enterprise
with
multiple
app
Unlimited
with
one
app
Unlimited
with
multiple
apps
SalesForce.com
Contact
Group
Professional
Enterprise

includes

editions
Manager
edition
edition

145

Unlimited

edition

How many custom objects available in Professional and Enterprise


edition
and
Unlimited?
Professional
50
Enterprises
200
Unlimited
2000
In Which edition the Apex Data Loader will support? What are those
editions?
Earlier Enterprise and Unlimited editions use to support Apex data loader. Now,
Professional, Enterprise and Unlimited edition supports data loader.
Through Sales force Import wizard how many records we can import
into S.F Objects and the wizard will support for which Objects?
Using Import wizard, we can upload up to 50000 records. And only Accounts,
Contacts and custom objects data can be imported. If we want to import other
objects like Opportunities and other objects data, then we need to go for Apex
Data
Loader.
In
which
edition
work
flows
are
available
in
S.F?
In Enterprise edition and in unlimited edition, we have these work flows. We do
not have these work flows in group and professional editions. We can get these
workflows
in
professional
edition
also
as
an
add-on.

What is the data and file storage capacity in Professional and


Enterprise and Unlimited editions Org wide? What is the storage
capacity
for
each
user
in
above
editions?
Data storage (Org)
File storage
(Org)
Dstorage/Fstorage(User)
Professional
1GB
1GB
20MB/100MB
Enterprises
1GB
1GB
20MB/100MB
Unlimited
1GB
1GB
120MB/100MB
In Which Edition Outlook and Excel and Mobile Lite are available in
S.F?
Mobile Lite users can view, create, edit, and delete accounts, assets, contacts,
leads, opportunities, events, tasks, cases, and solutions from mobile.
Mobile lite is available in all editions i.e.; Group edition, Professional edition,
146

Enterprise
edition,
Unlimited
edition.
Outlook connect to sales force is used to sync contacts, Events and mails to sales
force. Like mobile lite feature this is also available in all above mentioned editions.
What
is
app
exchange?
The developed custom applications can be uploaded into the app exchange so that
the
other
person
can
share
the
applicaition.
What
is
a
VLOOKUP
in
S.F?
VLOOKUP is actually a function in sales force which is used to bring relevant value
to
that
record
from
another
record
automatically.
What are the types of bindings available in Visual force?
Using get; set in apex, we can bind variables in visual force.
ex:
public
String
textdemo{get;set;}
//
in
apex
<apex:input
text
value={!textdemo}>
Using
Ex:

methods
in
controller
<apex:selectlist
value=textdemo>
<apex:selectoptions
value=listt/>

</apex:selectoptions>
//In
Public
Return
[select
}
What are
4
Master-Detail
Lookup
Junction
Hierarchy

the

List<Account>
Id,Name
from
Account];
types

of

relationships

\\

apex
getlistt(){
returns
list

present

in

S.F?
types
Object

What
is
junction
Object
and
what
does
it
mean?
Junction object is a custom object which is used to create many to many
relationship
between
two
objects.
It
always
contains
two
Master-Detail
relationships.
Differences
between
Master-Detail
and
Lookup
Both are used to create one to many relationship between two objects.
147

In
In

case
case

of MD, if Parent is deleted, child is also


of Lookup, if Parent is deleted, child is not

deleted.
deleted.

In MD, Child is mandatory, but in Lookup, child is not mandatory.


When I want to export data into SF from Apex Data Loader, which
Option
should
be
enable
in
Profile?
Enable
API
Types
of
Reports
in
S.F?
3
types
of
reports
in
S.F
Tabular reports: Tabular report is used to represent the data simply in tabular
format.
Summarizing on a particular field cannot be done.
Summary reports: In summary report, we can summate or group the data based
on
a
column.
Matrix report: In matrix report we can summarize the data both in rows and
columns.
What
is
an
Assignments
rule?
It is a Rule to specify how leads are assigned to users or queues as they are created
manually, captured from the web, or imported via the lead import wizards.
What
is
a
weblead?
Capturing a lead from a website and routing it into lead object in Sales Force is
called
wed-lead
(web
to
lead).
What is lookup and Master Details and what is difference between
them.
Both Lookup and Master detail fields are used to link a record in one object to
another
record
in
another
object.
In lookup, if we delete master records, child records will not be deleted.
In master-detail, if we delete master records, child records will also be deleted.
Child
record
is
mandatory
for
Master-Detail.
What
is
an
External
Id?
External Id is an id that can be given to any field in an object. An external id will
be generated on the field that we mention. This field will be used to detect
duplicate values when we try to import data into sales force using an external
system
like
apex
data
loader,
informatica
data
loader
etc.

148

What are the Types of Account and difference between them?


We
have
two
types
of
accounts.
Personal
accounts
Business
accounts.
In personal accounts, persons name will be taken as primary considerations
where as in business accounts, there will be no person name, but company name
will
be
taken
into
consideration.
How
many
ways
to
do
a
field
is
mandatory?
There are two ways to declare a field to be mandatory.
At the time of creating the field, mentioning the field should contain a value to
save
a
record.
In page layout, we can mention the field to be mandatory.
What

is

Field

level

Security?

Giving
permissions
to
users
based
on
Profiles.
Mentioning the availibity of a field to the users for viewing and editing purpose
based
on
profile
is
called
field
level
security.
While creating a field,we can mention the security level of that field fr every profile
by
deciding
its
level
of
accessibility
to
each
profile.
Difference
between
Formula
and
Roll-up
summary
Formula: is a read only field that derives a value from a formula expression that
we
define.
Roll-up summary: A read-only field that displays the sum, minimum, or
maximum value of a field in a related list or the record count of all records listed
in
a
related
list.
Difference
IsNull

IsBlank-

btw
it
it

isNull
supports
supports

for
for

and
Number
Text

isBlank
field.
field.

What is a workflow? Types of workflow and actions in workflow.


Workflow is a force platform business logic engine that allows us to automatically
send email alerts, assign tasks, field updates based on rules that we define.
2
types:
Immediate actions: That executes when a record matches the criteria.
Time-dependent: When a record matches the criteria, and executes according to
149

time

triggers.

Actions:
Task
:
Asign
a
new
task
to
user.
Email-alerts : Send email to one or more recipients that are specified.
Field
Updates
:
Update
value
of
a
field.
Outbound Messages: Send a configurable API message to designed listener.
Types
Text
Html
Custom
Visual

of

email

with

templates

letter

head
Template
Force.

Difference
btw
Profiles
and
Roles
Profiles: Field level or Object level security can be given by profiles
Roles:
Record
level
security
can
be
given
by
Roles.
Profile

is

Types
Manual
OWD
Public
Public
Private
Sharing
Role

mandatory.
in

roles:
Sharing

(organization

wide

default):

read
read/write
rules
Hierarchy

What
is
a
wrapper
class?
A wrapper class is a class whose instances are collections of other objects.
What
are
collections
and
types
of
collections?
Collection is an object which groups multiple elements into a single unit.
List:
Ordered
collection
of
elements
which
allows
duplicates.
Set: Unordered collection of elements which do not allow duplicates.
Map: Pair of two elements, in which the first element is always unique.
150

Types
of
Reports:
Tabular: Display data in a tabular form. No summarizing is allowed.
Summary: Summarize data on one column based on single criteria.
Matrix:
Summarize
data
on
both
row
and
columns.

Difference

between
VF

VF

and

S-Control
S-Control

It is a markup language like XML, HTML It is a procedural language like Java,


Ajax
Automation of data is there- Binding No automation of data- Manual Binding
Style
sheet(CSS)
is
included
CSS
is
not
included
Native
Accessibility
of
object
{! ($Objecttype.ObjectName.accessable)}----------- returns true if object is
accessible.
What
are
Global
keywords?
Used to access various values from components on a page or from user objects or
from
URL,
for
each
object
we
have
each
key
word.
URL
Profile
User
Resource

Current
Page
Object

Page
Reference
Type
Component

What
is
a
Page
Reference?
Page reference is a class in apex, which is used to redirect to another page.
By creating an object to this class, we can use this object to forward to another
page
as
shown
in
example
below:
Public
Pagereference
go()
{
Pagereference p = new pageReference(http://www.google.com);
Return
p;
}
What

is
151

MVC?

The main aim of the MVC architecture is to separate the business logic and
application
data
from
the
presentation
data
to
the
user.
Model: The model object knows about all the data that need to be displayed.
View: The view represents the presentation of the application (User Interface).
Controller:
Actual
business
logic
of
VF
is
present
here.
What
are
the
Controllers
available
in
Force.com?
3
types
of
controllers
are
available
Standard Controller: Used for both custom and standard objects.
Custom Controller: is an apex class that implements all the logic for a page
without
leveraging
the
functionality
of
a
standard
controller.
Extension Controller: is an apex class which adds functionality to existing
standard
and
custom
controllers.
What is a difference between render, rerender and renderAs?
Render: is an attribute used in VF to hide or show certain components in visual
force
page.
Rerender: Used to refresh a part of a page in visual force page when an action
occurs.
Render as: Used to convert entire visual force into PDF
Render
as
=
pdf.
How can you access URL Parameters in to a visual force page?
Using $CurrentPage, you can access the query string parameters for the page by
specifying the parameters attribute, after which you can access each individual
parameter.
$CurrentPage.parameters.parameter_name
Ex:

$CurrentPage.parameters.location

What
are
annotations
ant
their
types?
Annotations are used to bypass the methods in the way they execute.
@Future:
Used
to
execute
the
methods
asynchronously.
@IsTest:
Used
to
test
the
methods.
@ReadOnly
@Deprecated
@Remote
Action
What

is

difference

between
152

<apex:

dataTable

/>,

<apex:

pageBlockTable
Only
standard
If we want to
What
is
Sandbox
is
3
Configuration
Developer
Full

style
sheets
used
in
page
add custom style sheets we have
a
the

Sandbox?
Types
exact
replica
of

of
the

block
to data

/>?
table,
table.

sandbox.
production.
Types:

What
are
triggers?
Types
of
Triggers
Trigger is a piece of code that is executed before or after a particular field of certain
type
is
inserted,
updated
or
deleted.
Bulk Trigger: All triggers are bulk triggers by default, and can process multiple
records at a time. You should always plan on processing more than one record at
a
time.
Bulk triggers can handle both single record updates and bulk operations like:
Data
import
Mass
actions,
such
as
record
owner
changes
and
deletes
Recursive Apex methods and triggers that invoke bulk DML statements.
Recursive
trigger:
ActionSupport: A component that adds AJAX support to another component,
allowing the component to be refreshed asynchronously by the server when a
particular event occurs, such as a button click or mouseover.
ActionFunction: A component that provides support for invoking controller
action methods directly from JavaScript code using an AJAX request.
ActionPoller: A timer that sends an AJAX update request to the server
according
to
a
time
interval
that
you
specify.
What is Batch Apex? How can you implement Batch Apex?(Dynamic
Apex)
Batch Apex gives you the ability to operate over large amounts of data by chunking
the job into smaller parts, thereby keeping within the governor limits.
Using batch Apex, you can build complex, long-running processes on the
Force.com platform. For example, you could build an archiving solution that runs
on a nightly basis, looking for records past a certain date and adding them to an
archive.
What is a Callout method? How does it invoke, how many methods
available
in
Classes
and
Triggers?
153

It is used to invoke the External services HTTP or web services.


An Apex callout enables you to integrate your Apex with an external service by
making a call to an external Web service or sending a HTTP request from an Apex
script and then receiving the response. Apex provides integration with Web
services that utilize SOAP and WSDL, or HTTP services (RESTful services).
What is a difference between System log and debug log?
System Log console is a separate window that displays debugging information, as
well as its cumulative limits and source code. It can be considered a contextsensitive execution viewer showing the source of an operation, what triggered that
operation, and what occurred afterward. Use the System Log console to view
debug logs that include database events, Apex processing, workflow, and
validation
logic.
Debug log records database operations, system processes, and errors that occur
when executing a transaction or while running unit tests. The system generates a
debug log for a user every time that user executes a transaction that is included in
the
filter
criteria.
SOQL:
Salesforce.com
Object
Query
Language
SOSL:
Salesforce.com
Object
Search
Language
What
is
a
Force.com
IDE?
Ans. Force.com IDE is a development environment which is available as a plug-in
to be installed in Eclipse and used. This IDE can be used to work on and
manipulate the salesforce structure like authoring Apex classes, Visual force pages,
apex
triggers
etc.,
What is a Managed Package and Unmanaged package?
Unmanaged
vs.
Managed
Managed packages are AppExchange packages that can be upgraded in the
installer's organization. They differ from unmanaged packages in that some
components are locked, allowing the upgrade process. Unmanaged packages do
not
include
locked
components
and
can
not
be
upgraded.
Before the Winter '07 release, all packages were unmanaged. Now, you can
convert an unmanaged package to managed to ensure your installed users get
upgrades.
Unmanaged
Package
Managed
Package
What
Completely
Editable
by
Developer
and
Installer
Can
NOT
be
upgraded
Certain
Components
are
locked
No
Destructive
Changes
to
app
Supports
Seamless
Upgrading
154

Supports
LMA
for
Managing
Installs
When
to
Use
1:1
Distribution
Extensive
Modification
Required
1:Many
Distribution
Commerical
Intent
Foresee
Upgrades
Editions Supported All Editions can create Unmanaged Packages ONLY
Developer
Edition
can
create
Managed
Packages
Managed packages differ from unmanaged packages in many other ways. Before
creating managed packages, here are a few things to consider:
You must use a Developer Edition organization to create and work with a
managed
package.
A Developer Edition organization can contain a single managed package and
many
unmanaged
packages.
You must register a Namespace Prefix - A Namespace Prefix is a series of
characters prefixed to your Custom Objects and Fields to prevent conflict when
installed
in
another
salesforce.com
org.
When you release a managed package, meaning it is uploaded with the Managed
- Released option selected, the properties of its components change to prevent
developers and installers from making harmful changes. For a list of each package
component type and their properties, see Properties of Managed Packages. If you
do not want to offer upgrades to your package, consider keeping it unmanaged.
If you plan to release your app as a Managed Package, please read out guide on
Planning
the
Release
of
Managed
Packages
If you already have a Unmanaged Package and you'd like to convert it to Managed,
please review the following: Converting Unmanaged Packages to Managed
Now that you understand the difference and benefits of each type of package, let's
see how easy it is to make your Unmanaged package from above into a Managed
Package.
Customer
portal
With Salesforce CRMs customer portal, your customers can log cases and get
updates 24x7. All via the intuitive user experience for which Salesforce CRM is
famous. The resulthigher customer satisfaction at a lower cost.

155

Partner
portal
Outsource your service management by allowing third-party service reps to
manage customer cases via the partner portal. Service partners can do everything
they need to resolve customer support issues: search the solution database, log
cases,
make
case
comments,
and
run
reports.
53.What are the rules Criteria to create a work flow? How many ways
to fire a work flows and when should those available? What are the
actions
in
work
flow?
Ans. Criteria that cause salesforce.com to apply the workflow rule.
Immediate actions that execute when a record matches the criteria.
Time-dependent actions that salesforce.com queues when a record matches the
criteria,
and
executes
according
to
time
triggers.
In
2
ways,
1. Immediate action: when criteria matches record then workflow will be fired
immediately.
2.
Timedependent
action:
Fires
according
to
time
triggers.
Tasks - Assign a new task to a user, role, or record owner.
Email Alerts - Send an email to one or more recipients you specify.
Field Updates - Update the value of a field on a record.
Outbound Messages - Send a secure configurable API message (in XML format)
to a
designated listener.
54. Types of Sandboxes and what are those and In Which editions
those
are
available?
Ans. 3 types of Sandboxes available, those are Developer, Full and Configuration.
In
all
editions.
55. What is test coverage code % for the classes and triggers and what
is
the
test
method
syntax?
Ans.
75%.
56.Types
of
Triggers
and
what
is
a
Bulk
Trigger?
Ans. All triggers are bulk triggers by default, and can process multiple records at
a time. You should always plan on processing more than one record at a time.
Bulk triggers can handle both single record updates and bulk operations like:
Data
import
Bulk
Force.com
API
calls
Mass
actions,
such
as
record
owner
changes
and
deletes
Recursive Apex methods and triggers that invoke bulk DML statements.

156

57.What are the types of bindings available in Visual force?


Ans . 1. Using GET-SET in apex, we can bind variables in visual force.
2.
Using
methods
in
controller.
58.
What
is
a
Wrapper
Class
in
S.F?
Ans. A wrapper class is a class whose instances are collections of other objects.

Visual Force Interview Questions


Visual Force
1.
What are expressions used in pages to bind in controllers?
Using methods we can bind.
Getter:Will return value from controller to vf page
Setter:Will pass value from vf page to controller
Action:Will redirect to another page.
2.
What is the purpose of controllers?
Controllers provide the data and actions that are available to a Visualforce page.
3.
Which objects have associated standard controllers?
All standard and custom objects that can be accessed via the API have associated
controllers
4.
What is included with each standard controller?
Data: the fields for the associated object record that are API accessible, including
the related records (5 up/1 down). Actions: save, delete, view, edit, cancel.
5.
When do you need to go beyond a standard controller and code custom Apex?
If you need data beyond the limits of what is available in the standard controller
or actions that go beyond the provided standard actions.
6.
Compare and contrast custom controllers and controller extensions. How
are they the same? How are they different?
Both allow for custom code to be used, allowing for custom data sets and custom
actions. Extensions leverage the existing data and actions within a standard or
custom controller. Custom controllers must contain all data and actions that need
to be executed by the page. Extensions that extend standard controller allow for
the pages which use those extensions to be used in custom buttons, standard
button overrides, and over declarative features.
157

7.
What identifies a controller as being an extension?
The controller must declare a constructor which takes another controller
explicitly.
For
example:
public
myControllerExtension(ApexPages.StandardController stdController) {this.acct
= (Account)stdController.getRecord(); }
8.
Why are properties helpful in controllers?
Properties can automatically create standard getters and setters while still
allowing for their customizations. They save you from both writing the tedious
code and reading the clutter when reviewing code.
9.
In what order do methods fire within a controller?
The only rule is that setters fire before action methods. Aside from that, there is
no guaranteed order.
10. What are some Apex classes that are commonly used within controllers?
StandardController, SelectOption, PageReference, Message, etc.
11. How are wizard controllers different from other controllers?
The two main issues is that they must handle multiple pages and they must
maintain the state across those pages.
12. What are the effects of using the transient key word?
The transient key word prevents the data from being saved into the view
state. This should be used for very temporary variables.
13. When is a component controller required for custom components?
A component controller is required when business logic is required to decide how
to render the component.
14. What kind of content can be included in a Visualforce page?
Any content that can be rendered in a browser (HTML, JavaScript, etc.).
15. What do {!expressions} refer to when used in Visualforce
components?
Expressions refer to either data or actions that are made available to the page from
the controller
16. What are the ways that Visualpages can be incorporated into the rest of your
user interface?
Basically, via links, buttons, tabs, and inline frames.
17. Is it always necessary to know Apex to create Visualforce pages? When does
it become necessary?
No, it is not always necessary. You can use standard controllers and VF
component tags to accomplish quite a bit. Apex becomes necessary when you
need either a custom set of data or custom actions to be available from the page.
18. What are attributes? What is the syntax for including them?
Attributes are modifiers to the main tag that belong after the tag name in the start
tag. The syntax is attributeName=attributeValue
19. What are three types of bindings used in Visualforce? What does each refer
to?
158

Data bindings refer to the data set in the controller.


Action bindings refer to action methods in the controller.
Component bindings refer to other Visualforce components
20. What is the main difference between using dataTable vs. pageBlockTable tags?
PageBlock: For default salesforce standard format.
dataTable:To design customformats
21. Which tag is used with both radio buttons and picklists to create the selectable
values?
<Apex:selectoption> tag
22. How many controllers can a page have? Where is the controller for a page
assigned?
One main controller (of course, it could have extensions or custom components
could have controllers, etc.). The controller is assigned in the <apex:page> tag.
23. There are a series of layout components that all help recreate the traditional
Salesforce page layout style very easily. What name do they share?
pageBlock.
24. Which tags should be used to automatically bring in the Salesforce label and
default widget for a field?
pageblock
25. What are static resources?
Static resources are a new type of storage in Salesforce specifically designed for
use in Visualforce pages. They are ways to store images, flash files, stylesheets,
and other web resources on the Salesforce servers that can be cached for better
page performance.
26. What are some examples of JavaScript Events?
Onmouseover, onclieck etc.
27. What is AJAX typically used for in Visualforce
AJAX is primarily used for partial page updates in Visualforce. In s-controls, the
AJAX toolkit was the soap (XML over HTTP) client that gave you access to the
force.com Web Services API.
28. What is the purpose of <script> tags?
Script tags allow you to create JavaScript (or other types) functions that can be
used within your pages
29. What are the different AJAX action tags? What does each do?
actionStatus: used to display start and stop statuses of AJAX requests.
actionSupport: used to call a second component when an event
happens to the first component.
actionPoller: similar to actionSupport, but the event is based on a
timer instead of a user action.

159

actionFunction: provides support for invoking a controller action


from JavaScript code using an AJAX request by defining a new
JavaScript function.
actionRegion: used to demarcate which parts of the page the server
should reprocess.
30. How can you create partial page refreshes?
Basically, you need to define the section of the page that is going to refresh
(typically with a panel of sorts), and then define the event that will cause the
refresh. The method changes depending on if the area being refreshed is the same
as the one handling the event. It also depends on if you are just processing
something on the server, or if you need the UI to change.
31. Which tag is used with both radio buttons and picklists to create the selectable
values?
<apex:selectOption>
32. What is the purpose of creating attributes on components?
By allowing the component to take parameters via an attribute, you can make the
component more flexible and reusable
33.What are the Global Key words?
We have global keywords like component,User,url,current page etc., to access
various values from components on page, from user object or from url or from
current page fields. To access value from each source, we have different global
keywords. One such keyword is explained in above question(!$component)
Various global keywords are:
i.
URL
ii.
USER
iii.
PROFILE
iv.
Resource
v.
Component
vi.
Current page
vii.
Page reference etc.
34.How can you access visualforce components values into a JavaScript?
Using Component global variable, we can access visualforce components in
javascript. Let us suppose, we want to use id of an apex field with id=afield.
So, we can use the {!$Component.afield} syntax to use properties of the field in
javascript.
Let us suppose, we want to store the fields value in java script, then we can use
like below:
<script>
Var a = document.getElementById('{!$component.afield}').value;
</script>
160

35.What are the Gov Limits in Salesforce.com?


Because Apex runs in a multitenant environment, the Apex runtime engine
strictly enforces a number of limits to ensure that
runaway scripts do not monopolize shared resources. These limits, or governors,
track and enforce the statistics outlined in the following table. If a script ever
exceeds a limit, the associated governor issues a runtime exception that cannot be
handled.
Governor limits can be extended from release to release.
Trigger
Total number 20
of SOQLs
Total 0
number
of
SO
SLs
Total number 1000
of
records
Retrieved by
single SOQL
Query
Total number 0
of
records
Retrieved by
single SOSL
Query
Total Number 10
Of Call out
Methods
Total number 10
of send email
methods
allowed
Total
Heap 300000
Bytes
Size

Class
100

Test
100

20

20

10000

500

200

200

10

10

10

10

3MB

1.5MB

161

Apex
1.
What is the biggest difference between Apex and most programming
languages?

Apex provides built-in Data Manipulation Calls(Like Insert,Update,Delete


etc.,)without establishing any connections to database and closing the
connections.

It provides default exception handling which throws an exception message


automatically onto the screen unlike in other programming languages which
throws error on to error console and shows abnormality.
But, Apex handles the exception and shows us on the page.

Embedded SOQL (Salesforce Object Query Language)and SOSL(Salesforce


Object Search language) queries which returns the SObject results.

Apex is interpreted(compiled), executed and Controller by Force.com


platform.
2.
Where can Apex be authored? Where can it be executed?
Apex can be authored on Force.com editor which is provided in
Salesforce SETUP pane on left side.

Apex classes are executed on Force.com platform. It cannot be executed on Local


machines using tomcat or any other servers.
3.
Why are governor limits important? What are they based on?
A.
Governor limits are important because it controls the user to use the
database interactions with limited control. Since, Force.com is a cloud platform ,
it offers multi-tenancy which provides unit platform for various Force.com
tenants. If the governor limits are not set, and if most users start interacting with
cloud database with no limit, then obvious burden will be imposed on Cloud.So,
governor limits are important which determine the total pages visited by a client
162

and total number of page navigations, a client can do in a day, total data base
interactions that can be made in a single go.
Governor limits are based on the type of the Org we use.Generally, testing org
contains different governer limits(more), and production org contains different
governor limits(less).
4.
List a few characteristics of Apex that is different than other
programming
languages.
A. Apex is strongly typed language with direct references TO Sobject and fields
names.
Apex is interpreted, Executed, Controlled by Force.com platform.
Apex scripts can be saved against different versions of the Force.com API.
5.
How would an external program access functionality on Force.com platform?
We have a concept called Web Services. Using this extended functionality,
we can make external program access the functionality on Force.com platform.
We will generate WSDL document(Web Services Description Language) which
will be exposed to host environment which results in extending the capability of
accessing Force.com platform from external program.

6.
What are governor limits? Why are these important in a multitenant
environment?
A. Governor limits are the database limits that are applied to the users who use
Force.com platform. Governor limits simply means the limited database calls that
a
developer/user
do.
These governor limits are important because unlimited and free access to
database many number of times from each time will slow down the database
effectiveness.So,to preserve the database effectiveness, governor limits are
important in multi-tenant environment.
7.
What is Run time type information? How do obtain it in Apex?
A.
Run time type information refers to a system that keeps the information
about an objects data type in memory at run time. This run time information
deals to integers, strings and generic objects.
8.
How
do
you
override
a
method
in
Apex?
A.
With the help of the OVERRIDE key word in method signature, we can
override
a
method
in
Apex.
For example, we have a method public void abc(){
},
If we want to override the method, we can do like below:
Public override void abc(){
}
163

9.
What are the ways in which Apex can be invoked?
A. We can invoke apex in 4 ways:
a.
Triggers: By writing the apex triggers,and calling them on the 7 pre defined
events of creating/modifying a record, we can invoke apex.
b.
Apex Schedule: We can schedule Apex code to be run at a particular
point/for a particular period of time. We need to write some Apex code and
schedule them using Apex Scheduler.By this way, we can invoke apex.
c.
Anonymous Blocks: Anonymous Block refers to a block, from where we can
invoke apex by writing the logic we need. Example is as below:

d. Apex in Ajax: For Apex, we have ajax took kit, from where we can do Apex
calls. This Ajax toolkit can be used on the visualforce page using javascript
notations. Using this Apex in Ajax, we can invoke Apex.
10. What are some of the limitations of code that you can call via the
anonymous
block?
A.
Anonymous Blocks code execute with current users permission. So, if the
user does not have field-level permissions or does not have profile permissions,
then the code in anonymous block fails.
11. How do you expose functionality on Force.com to be consumed by
external
clients?
A.
We have a concept called Web Services. Using this extended functionality,
we can make external program access the functionality on Force.com platform.
We will generate WSDL document(Web Services Description Language) which
will be exposed to host
environment which results in extending the capability
of accessing Force.com platform from external program.
12. What would the syntax be to create a new class named
MyNewClass
which
should
be
public?
A.
Syntax
is:
Public class MyNewClass{
}
Here public is the access modifier for the class. And CLASS is the keyword to
designate a class and MyNewClass is the name of the class.
13. What is the difference between the global and public access
modifier
keywords?
A.
We have different access modifiers like global, private, public.
If we use the access modifier as Global, it can be used anywhere in the org.
Generally, Global is used for web-services since one class needs to handle some
other parts of apex in the org. Whenever we use Public keyword, then the access
is limited to the particular class and cannot be used outside the related class.
164

14.

Is casting between a String and Integer allowed?


Allowed
15 .What are different data types for Apex variables?
Premitive and non premitive data types
16.What keywords are used to declare a constant?
Final and static
17.What special characters are used to surround SOQL or SOSL queries?
[ and ]
What is the maximum number of rows that can be brought back by a SOQL
query?
o 50000
What advantage does using a variable list in a for loop have over a single
variable?
o Using list ,we save retrived data in a single list variable
What is different about a static method?
o Static methods are not used in web services
What are the two types of iterations that can be performed in a for loop with a
SOQL query?
o Variable and variable_list
Does Apex use explicit transactional calls such as commit and rollback?
o NO
The assert family of methods belong to which class?
o System
What do the Limit class methods help you to manage?
How do you access the records that cause the trigger to execute?
What are the seven different types of trigger events?
o Before insert,before update,before delete
o After insert,after update,after delete,after undelete
How do you specify that a trigger is a bulk trigger?
o By default all triggers are bulk triggers
Under what identity do triggers execute? What ramifications does that have?
Is it necessary to import a WSDL to perform a callout?
o NO
What does the @future annotation do? What are the other annotations
available with Apex?
o @future is used to execute methods asynchronously.
o @istest,@readonly,@remoteAction,@depricited
:11:#tb0#Oid black 1.0pt; border-top:none;mso-border-top-alt:solid
black .5pt;mso-border-alt:solid black .5pt; padding:0in 5.4pt 0in 5.4pt'>
Total Heap Size
300000 Bytes
3MB
165

1.5MB
Interview Questions:
1) Internalization or localization of salesforce?
- Currency
2) Many to Many
3) Consumption
4) Rollup Summary
5) Package import and export
6) Debug Log files
7) Primary Key and Foreign Key.
8) Report Schedule
9) Change Sets or Individual object Creation
Change set are used to move configurations from one system to the other (for
example... partial sandbox to full sandbox) BUT not the records
10) number of levels when you write query
When designing relationship queries, consider these limitations:
Relationship queries are not the same as SQL joins. You must have a relationship
between objects to create a join in SOQL.
No more than 35 child-to-parent relationships can be specified in a query. A
custom object allows up to 25 relationships, so you can reference all the child-toparent relationships for a custom object in one query.
No more than 20 parent-to-child relationships can be specified in a query.
In each specified relationship, no more than five levels can be specified in a childto-parent relationship. For example, Contact.Account.Owner.FirstName (three
levels).
11) Custom Report Type:
166

with or without
selective feilds

Kalyan's interview - 07/11/14


1) Profile vs Permission Set
2) OWD? when? Why?
3) How move configurations from partial or configuration sandbox to full
sandbox(production server)?
Metadata API - Config and Data
Bulk API - Data only
Change Sets - Configurations only
Soap API - Less Records (upto 200 hunders records)
REST API - Less Records(upto few thousands records)
4) How many types security acess?
5) Dataloader & import wizard?
Import wizard supports A&C, L and Solns & all customer objects
Dataloader supports most of the standard (including case, Opps, ...) and all
standard objects.
6) Moving data from legacy system to salesforce
Data conversion Audit Fields Raising case The difference between lastmodifiedDate and SystemModStamp?
7) Report Secnarios
Types of reports:
- Custom Reports & Standard Reports
* with or without (lookup or master-detail) & With (Master-detail)
*remove unwanted feilds from view by editing layout & Can't remove.
8) Hiding fields from pageout? Can we access else where?
9) Communities & Portal, Severice Cloud, Solutions & Cases.
10) Sequence of VF GET method:
https://www.salesforce.com/us/developer/docs/pages/Content/pages_controll
er_get_request.htm
11) SOAP API, webservices.
12) How do start retrive a particular record using SoQL.
OFFSET starting point
167

LIMIT Total number of records


13) Ajax
14) Prompting error in VF or Apex
Apex - Adderror
VF - Pagemessage
15) Exceptions?
What is expection? and where do we use?
16) Custom controller extensions?
Scenario
5 objects
All the records from the all objects.
(Create a example program)
If they are related or unrelated?
17) SoSL statements
SoSL - You can search any field across your salesforce instance whether related or
unrelated.
SoQL - You can query from a single object or from a related objects.
18) Webservices and Callouts.
19) How do avoid recurssive trigger?
Use helper class with static boolean variable where we set to true when the trigger
is already fired and set to false when the trigger not even fired once.
(write an example trigger)
20) User Context & System Context.
User mode ONLY in test classes.
21) Trigger Context Variables:
new Returns a list of the new versions of the sObject records.
Note that this sObject list is only available in insert and update triggers, and the
records can only be modified in before triggers.
old Returns a list of the old versions of the sObject records.
Note that this sObject list is only available in update and delete triggers.
168

22) Pagination & @future annotation

Note: We can not create time-dependent workflow when we choose created or


everytime it's edited option.
- SSO
- Marketo

Create a trigger to escalate the case to Manager by sending an email if


the case severity is HIGH?
trigger CaseEscalationTotheMangaer on Case (after insert) {
//case c=trigger.new[0];
for(case c:trigger.new)
if(c.Priority=='High')
{
messaging.singleemailmessage mail=new messaging.singleemailmessage();
mail.setToaddresses(new string[]{'ChinthamRR@gmail.com'});
169

mail.setreplyto('chintham@rnritsolutions.com');
mail.setsenderdisplayname('Raveendra');
mail.setSubject('High Severity Cases has been created');
mail.setplaintextbody('Sev 1 case created.. Please assign to SME');
messaging.sendemail(new messaging.singleemailmessage[]{mail});
}
}
Create a trigger to make the record READ-ONLY when the field 'Active' (Active is
custom field, Active__C) is set to 'YES' for an account record?
trigger MakeRecordsReadOnlyWhenActiveIsSet on Account (before update) {
if(trigger.new[0].active__c == 'Yes')
trigger.new[0].adderror('Can not be updated');
}
Create a apex program to insert user?
public class TestStandardUserInsert {
public static void insertuser()
{
insert (new User(firstname = 'Vaishni Reddy 09-05-2015 06-11-45',lastName =
'Chintham',email = 'VaishniReddyChintham' + '@RNRITSolutions.com',
Username = 'VaishniReddyChintham' + '@RNRITSolutions.com',
EmailEncodingKey = 'ISO-8859-1',
Alias='Vaishni',
TimeZoneSidKey = 'America/Los_Angeles',
LocaleSidKey = 'en_US',
LanguageLocaleKey = 'en_US',
ProfileId = [select id from profile where name='Standard User'].id));
}
}

170

Test Class:
1) Why do I see below error message?
System.DmlException: Insert failed. First exception on row 0; first error:
UNKNOWN_EXCEPTION, portal account owner must have a role: []
Error Portal account owner must have a role
Description
System.DmlException: Insert failed. First exception on row 0; first error:
UNKNOWN_EXCEPTION, portal account owner must have a role: []
Resolution
This error is generated because the user was not assigned a role.
171

You will also see this same error (for the same reason) when trying to enable a
contact as a partner or customer portal user.
The

following

sample

code

demonstrates

how

to

avoid

this

error:

Account a = new Account(Name='Test Account Name');


insert a;
Contact c = new Contact(LastName = 'Contact Last Name', AccountId = a.id);
insert c;
User user = new User();
user.ProfileID = [Select Id From Profile Where Name='Some Profile'].id;
user.EmailEncodingKey = 'ISO-8859-1';
user.LanguageLocaleKey = 'en_US';
user.TimeZoneSidKey = 'America/New_York';
user.LocaleSidKey = 'en_US';
user.FirstName = 'first';
user.LastName = 'last';
user.Username = 'test@appirio.com';
user.CommunityNickname = 'testUser123';
user.Alias = 't1';
user.Email = 'no@email.com';
user.IsActive = true;
user.ContactId = c.Id;
insert user;
System.RunAs(user) {
// do all of my tests
}
What is a Visualforce Page ?
Ans: Visualforce is the new markup language from salesforce, by using which, We
can render the standard styles of salesforce. We can still use HTML here in
Visualforce. Each visualforce tag always begins with apex namespace. All the
design part can be accomplished by using Visualforce Markup Language and the
business logic can be written in custom controllers associated with the Page.
In

Which

sequence

Trigger

and
172

automation

rules

run

in

Salesforce.com The following is the order salesforce logic is applied to


a record.
Old record loaded from database (or initialized for new inserts)
New record values overwrite old values
System Validation Rules
All Apex before triggers (EE / UE only)
Custom Validation Rules
Record saved to database (but not committed)
Record reloaded from database
All Apex after triggers (EE / UE only)
Assignment rules
Auto-response rules
Workflow rules
Escalation rules
Parent Rollup Summary Formula value updated (if present)
Database commit
Post-commit logic (sending email)
There is no way to control the order of execution within each group above.
How to restrict any Trigger to fire only once ?
public class HelperClass {
public static boolean firstRun = true;
}
trigger affectedTrigger on Account (before delete, after delete, after undelete)
{
if(Trigger.isBefore){
if(Trigger.isDelete){
if(HelperClass.firstRun){
Trigger.old[0].addError('Before Account Delete Error');
HelperClass.firstRun=false;
}
}
}
}
How to display error messages in the visualforce page ?
In Apex use below code to create the error message for visualforce.
1
Apexpages.addMessage(
new
ApexPages.Message
173

(ApexPages.Severity.ERROR, 'Required fields are missing. '));


in Visualforce page add below tag where you want to display the error message.
<apex:pageMessages ></apex:pageMessages>
What is property in Apex? Explain with advantages.
Apex mainly consist of the syntax from the well known programming language
Java. As a practice of encapsulation in java we declare any variable as private and
then creates the setters and getters for that variable.
private String name;
public void setName(String n)
{
name = n;
}
public String getName()
{
return name;
}
However, the Apex introduced the new concept of property from language C# as
shown below:
public String name {get; set;}
It will be very useful when lots of member is declared in Apex class. It has another
advantage in number of lines of code limit by salesforce which will drastically
reduced.
How to read the parameter value from the URL in Apex?
Consider that the parameter name is RecordType.
String recordType = Apexpages.currentPage().getParameters().get('RecordType');

In How many way we can invoke the Apex class?

174

Visualforce page
Trigger
Web Services
Email Services
What are different DML Methods in SalesForce?
Data Manipulation Language (DML) methods help to perform different data base
transactions/operations.
SalesForce supports DML Statements like insert, update, delete, undelete. This is
called APEX
DML Statements
Alternatively, SalesForce supports Database DML Statements. We can perform
DML operations
by calling the methods provided by the Database class.
Database.insert
Database.update
Database.delete

What is the difference between database.insert and insert ?


insert is the DML statement which is same as databse.insert. However,
database.insert gives
more flexibility like rollback, default assignment rules etc. we can achieve the
database.insert
behavior in insert by using the method setOptions(Database.DMLOptions)
Important Difference:
If we use the DML statement (insert), then in bulk operation if error occurs, the
execution will stop and Apex code throws an error which can be handled in try
catch block.
If DML database methods (Database.insert) used, then if error occurs the
remaining
records will be inserted / updated means partial DML operation will be done.

What is difference between trigger and workflow?


Workflow: Workflow is automated process that fired an action based on
Evaluation criteria and rule criteria.
175

We can access a workflow across the object.


We cannot perform DML operation on workflow.
We cannot query from database
Trigger:
Trigger is a piece of code that executes before or after a record is inserted or
updated.
We can access the trigger across the object and related to that objects
We can use 20 DML operations in one trigger.
We can use 20 SOQLs from data base in one trigger.
What is Wrapper class?
A Wrapper class is a class whose instances are collection of other objects.
It is used to display different objects on a Visual Force page in same table.

176