Spread the love


Salesforce Visualforce Interview Questions and Answers

Can ‘set’ store duplicate values in it?

No. Set only stores unique values. List can have duplicate values in it.

Can two users have the same profiles?


How can you refresh a particular section of a visual force page?

This can be done using reRender attribute

How to get current logged in users id in apex ?

Use Userinfo.getuserid() to get the current logged in user’s id in apex.

How to convert a CSV file browsed in visualforce page into a string?

Use csvfilecontents.tostring(). method to convert blob to string

How to fire dynamic query in SOQL?

Using database.query Example: List accList = Database.query(‘select name from account’);

What is a bucket field in reports?

This field is used for the custom grouping of values in a field. This can be used in summarizing the report.

What are dynamic dashboards?

Dashboards which run for logged in user are dynamic dashboards

Can the dynamic dashboards be scheduled?

No they cannot be scheduled.

How can you use a custom label in visual force page?

Use this syntax for accessing custom label in visualforce page – {!$Label.Samplelabel}

What are the types of custom settings in salesforce?

List type and Hierarchy type

What are the different types of collections in apex?

There are three types of collections in apex language. They are Set, List and Map

What are maps in apex?

Map has keys and values. A key points to a single value. Map can be used to store relationships between two entities. Keys in map are unique. Values can be duplicated.

What are the different types of object relations in salesforce ?

They are One to Many, Many to many and Master-detail

Can you have roll up summary fields in case of parent child relationship?

No. These are present only in case of master details relationship.

What is the difference between action function and action support ?

Action functions can call controller method from java script, action support adds support to other components.

What is action poller in visualforce ?

Action poller sends AJAX request with a specified time interval.

What are the different types of reports available in salesforce?

They are tabular report, Summary Report, Matrix Report and Joined Report

How many active assignments rule can you have in lead/Case?

You can have only one active assignment rule at a time.

How do we access static resource in visualforce?

Use this syntax for accessing static resource {!$Resource.Testresourcename}

How to enable inline editing in visualforce page ?

You can enable inline editing in visualforce page by using component.

What is in trigger ? is a list of records that are in the context of trigger or because of these records(modification, Creation, deletion) the trigger has been called

How do we bulkify the trigger ?

Bulkfification requires iterating over all the records in trigger context for example : for(account ac: { // your logic here }

How can we get the old value in trigger?

use trigger.old map for getting previous values of fields.

Can we modify records directly in is a read only list, but field values can be changed in case of before trigger.

What does the error “list has no rows for assignment” mean?

it means the list you are trying to access has no values in it.

What should we do to avoid view state error in visualforce page?

Clear unused collections, define variable as transient.

What is a sandbox org?

It is the exact copy of your production org.

What is sosl?

select query that can return records of multiple objects as list of lists.

What is the full form of AJAX?

it stands for asynchronous java and XML

How can you show a custom error message in trigger?

This can be done using addError() method in trigger

What is the use of future annotation?

Future method starts execution when Salesforce has resources available.That is for asynchronous execution.

How to identify if a class is a test class?

test class always begins with @isTest

How to convert a blob variable into a string?

Use toString to convert blob into string

What are the different methods of batch apex class?

Start method, execute method and finish method

What is’ with sharing’ in apex class code?

When you use ‘with sharing’, user’s permissions and field-level security are respected. In case of ‘without sharing’ code runs in system mode.

Can you use dml statement in visualforce compoenent controller ?

To use dml in visualforce component you have to declare allowdml=true in visualforce component otherwise you will get an exception “DML is currently not allowed”

Can you write sosl in trigger?

Earlier this was not allowed but now sosl are allowed in triggers.

Which are the different access modifiers in apex?

Private, Public, Protected and Global are the four access modifiers allowed in apex.

Can you change the master of a detail record in salesforce ?

Yes provided you have ticked marked “Allow reparenting” in field setting otherwise the field is read only and master cannot be changed.

How can you lock records in apex?

Use For update in query to lock the record.For example: [select id,name from contact limit 20 For update];

What is visualforce component ?

It is a piece of code that can be reused. It can be encapsulated in other visualforce pages.

How can you display the status of an AJAX update request in a visualforce page ?

To display AJAX request status we can use component.

How can you access custom label in apex:

Yes, string custLabelstr = System.Label.LabelNamehere

How can you get all the keys of a map variable ?

Use method keyset() for this Set idSet = mapname.keyset();

How can you compare values of a picklist field in validation rule?

For comparing picklist value use ispickval ISPICKVAL(picklist_field, text_to_compare)

What are the different types of sandboxes in salesforce ?

Developer, Developer Pro, Partial Data and Full are the types of sandboxes in salesforce.

How can you make fields required on a visualforce page?

mark required = true

How can you implement custom functionality for a standardcontroller visualforce page?

This can be done by associating a controller class with that standard controller using “Extensions”

How can you get the current record id in a visualforce page ?

use ApexPages.CurrentPage().getparameters().get(‘id’) to get the current record id in visaulforce page.

Can a user change his own profile in salesforce ?

No, a user cannot change change his own profile.

Can a user change his own role?

Yes this can be done !!

Reset security token option is unavailable in set up. What could be the reason?

If in the profile setting “login ip ranges” have been set up then the option of “reset security token” is unavailable.

What are the different data types that a standard field record name can have?

Record name field can have either of the two data types : Auto Number or Text data type

Can you edit a apex trigger/apex class in production environment ?

No apex trigger /class cannot be edited in production.

Can you edit a visualforce page in production environment ?

Yes this can be done but cannot be associated with any controller

How can you deliver a visualforce page in excel form ?

use contentType=”application/” in page component of visualforce page

What is

It is a list of records in current context in a trigger.

How can you create a input field for date on a visualforce page ?

To create a input date field on vf page you will have to bind it with a existing date field on any object.

How can you convert a text to upper string ?


How can you convert a integer into a string ?


What are the different types of email templates that can be created in salesforce?

Test, HTML (using Letterhead), Custom (without using Letterhead) and Visualforce.

How can you display different picklist values for picklist fields in different page layouts?

This can be done using record types.

Can you do a dml in constructor?

No this cannot be done.

What are the data types that can be returned by a formula field?

They are Checkbox, currency, Date, Date/Time, Number, Percent and Text

Can you create a new profile from scratch ?

No, you have to clone from a existing profile and modify the settings as required.

What are custom labels in salesforce?

Custom labels are custom text values that can be accessed from apex codes and visualforce pages.

Can you use sharing rules to restrict data access?

No, sharing rule can only give wider access to data it cannot restrict data access.

Can you edit roll up summary field values in a record?

No, roll up summary fields are read only and cannot be edited.

How can you create relationship between two objects in salesforce?

Relationship can be set up by crating either look up relationship field or master detail relationship fields on objects.

Can you create a roll up summary field on parent object?

Roll up summary fields can only be created if the relationship between objects is master detail type.

How can you place an entire visualforce page in a different visualforce page?

This can be done using include attribute.

How can you hard delete records in apex?

use emptyrecyclebin method as below . ex- delete myAccList; DataBase.emptyRecycleBin(myAccList);

What all data types can a set store?

A set can store all primitive data types and sObjects but not collections.

What is the use of offset keyword in a soql query?

Using offset keyword return the records starting from desired location in the list. For example if we specify offset then all the records starting from location onwards would be returned.

How can you display an image as an field in a detail page of record?

This can be done using IMAGE function. A url of the image stored in document should be given in image function

When a lead is converted into account/contact will the trigger on account/contact fire?

In set up we can enable or disable whether triggers should run on conversion.

What happens to contacts when an account is deleted?

When an account is deleted all the contacts under it gets deleted.

What is an sObject type?

sObject refers to any object that can be stored i platform database. ex. sObject s = new contact()

How many elements can be stored with in a collection(list,set,map)?

There is no limit on the number of elements that can be stored in a collection. However, we need to consider the heap size limit.

Expand SOQL and SOSL.

SOQL- salesforce object query language, SOSL – salesforce object search language.

What is the difference between soql and sosl?

SOQL can query records from a single object at a time, while sosl can query records from multiple objects. SOQL returns a list while SOSL returns list of lists.

How can you query all records using an soql statement?

This can be done using ALL ROWS keyword. This queries all records including deleted records i recyclebin.

What is the use of @future annotation?

Using @future annotation with a method executes it whenever salesforce has resources available.

What is the significance of static keyword?

Methods, variables when defined as static are initialised only once when class is loaded.Static variables are not transmitted as part of view state for a visualforce page.

Can custom setting be accessed in a test class?

Custom setting data is not available default in a test class. We have to set seeAllData parameter true while defining a test class as below. @isTest(seeAlldata=true)

What is the difference between role and profile?

Role defines record level access while profile defines object level access.

On which objects can you create Queues?

Queues can be created on two standard objects (Lead and case) and also on all custom objects.

What are the different ways to invoke apex code?

Apex code can be invoked using DML operation(trigger), Apex class can be scheduled using schedulable interface(ex. batch apex), apex code can be run through developer console, an apex class can be associated with a visualforce page.

Can you create sharing rules for detail objects?

No. Detail objects cannot have sharing rules as the detail objects do not have owner field with them.

How can view state error be avoided?

Use transient keyword with variables wherever possible, clear unused collections. Use form tag in a visualforce page.

What is the use of writing sharing rules?

Sharing rules extend the record/data access level which is set using OWD, role hierarchy.Sharing rule cannot restrict the data visibility but can only widen it.

Which all field data types can be used as external ids?

An external id can be of type text, number or email type

What is a mini page layout?

Mini page layout defines fields and related list to be displayed in hover detail and console tab. Whenever you hover mouse over any recently viewed record the fields are displayed, related list isnot displayed(fields can be set in mini page layout).Console tab fields and related list on the right hand side are also controlled by mini page layout.

What is the use of console view/console tab?

Console gives list views and related list records for multiple objects on a single screen without any customization (visualforce page or controller)

What is @future annotation in apex?

It is used to indicate that code should be executed asynchronously when salesforce has available resources.

What are the different considerations that must be followed when using @future annotation in apex method?

Method must be static, It must return void and method can have argument of type primitives, collection of primitives or arrays of primitives

What is the difference between List type custom setting and Hierarchy type custom setting?

List type stores static data that can be used in apex code as it is examples could be country codes,currencies etc.Hierarchy type stores data that may change depending on user,profile or org wide default

Where can custom setting data be accessed?

Custom setting data can be accessed in formula fields,validation rules,workflow rules,apex,API

What different return types can be returned by SOQL?

A SOQL can return List of objects, a single object or an intege

What are the different exceptions in apex?

Apex exceptions can be built in or we can also create our own custom exceptions.Exception class is the super class of all the built in exceptions.So as to create a custom exception the class name should end with string ‘exception’ and it should extend any of the built in exception class or other custom exception class

What are governers limit in salesforce?

Governers limit are run time limits that are enforced by salesforce. Governers limits are reset per transaction.

What is an apex transaction?

An apex transaction represents set of operations that are executed as a single synchronous unit.

What does heap in apex mean?

Every apex transaction has its heap. Heap is nothing but the garbage collected at the end of every apex transaction.

How can you expose an apex class as a REST web service in salesforce?

An apex class can be exposed as REST web service by using keyword ‘@RestResource’

What are custom controllers?

Custom controller is an apex class that implements all of the logic for a vf page without leveraging standard controller

Can a custom controller class accept arguments?

No. A custom controller cannot accept any arguments and must use a no argument constructor for outer class.

What different type of method can be defined for VF controllers?

getter methods, setter methods and action methods

What are getter methods, setter methods?

Getter methods retrieve data from controller while setter methods pass data from page to controller.

What is Organisation Wide Default in salesforce?

Organization wide default is used to set default access level for various standard objects and all custom objects. Default access can be set as Public read only, Public read write, Public read write and transfer for different objects.

Can you set default access in Organization wide default for detail objects (detail object in case of master detail relationship)?

No, Detail object will always have default access as ‘Controlled by Parent’ and it cannot be changed.

Can you create sharing rules for detail objects?

No, this cannot be done.

Can standard object appear as detail object?

No, you cannot have standard object as detail object in case of master detail relationship.

What are the differences between list and set?

Set stores only unique elements while list can store duplicates elements.elements stored in list are ordered while those stored in set are unordered.

What is Actionsupport in Salesforce?

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

What is Action Region in Salesforce?

actionRegion provides an area of a Visualforce page that decides and separates which components should be processed by the server when an AJAX request is generated. … We will still use reRender attribute on action component to decide area which should be rerendered AJAX request completes

What is view state in Salesforce?

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

What is remote action in Salesforce?

Remote action function in salesforce allows user to access any method from any class through javasrcipt methods, and get the result as a javascript object for further manipulation. Points to remember while implementing remote action function: Remote action method should have @RemoteAction annotation

What is Salesforce Actionpoller?

Action poller acts as a timer in visualforce page. It is used to send an AJAX request to the server depending on the time interval (time interval has to be specified or else it defaults to 60 seconds). In the action attribute a controller method gets called

How many records we can print in a Pageblock?

There are times where there are more than 1000 records in the collection to be rendered. When this occurs, the Visualforce collection limit of 1000 is hit and the page doesn’t load

What is future method Salesforce?

The Future Annotation is used to execute a method asynchronously in Salesforce. For example, we can use the future method to make a Web Service callout from an Apex Trigger. Methods with the future annotation must be static and can only return void data type.

What is Pagereference in Salesforce?

The PageReference is one of the most commonly used classes in Visualforce programming. In general, an instance of the PageReference class can be used to refer to another web page

For which criteria in workflow “time dependent workflow action” cannot be created?

created, and every time it’s edited

What is the advantage of using custom settings?

You dont have to query in apex (fire select query) to retrieve the data stored in custom settings.

What is the difference between a standard controller and custom controller

Standard controller inherits all the standard object properties, standard button functionalities can be directly used. Custom controller defines custom functionalities, a standard controller can be extended to develop custom functionalities using keyword “extensions”

Can you have more than one extensions associated with a single page?

Yes we can have more than extensions.

If page is having multiple extensions and if two extensions have methods of same name. Then which method out of these two will be called upon calling from vf page ?

The one which is present in the controller defined on the left side will be called.

What are governor limits ?

Governor limits are the limits imposed by salesforce so as to avoid monopoly by orgs in using salesforce shared resources.

How can we implement pagination in visualforce ?

use standardset controllers for implementing pagination.

How can you override a list button with a visuaflorce page?

Visualforce page should be a list controller that is it should have “recordsetVar” attribute defined in page tag.

What are different ways of deployment in salesforce ?

Change sets, eclipse and ANT

Is it possible to bypass Grant Access Using Hierarchies in case of standard objects ?

No. This is default and cannot be changed.

How can you call a controller method from java script ?

Use action function component to call controller method from java script.

How can you call a visualforce page from a controller method?

Use pagereference object for calling a visualforce page from controller method.

How can you sort a select SOQl query ?

Use order by clause in select query for sorting a list of records.


Learn more about salesforce admin 

salesforce lightning interview question and answers

Keep visiting us to know more about Salesforce Apex Interview Questions and Answers

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most popular

Most discussed