Visualforce Interview Questions

What is Action support 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 mouse over.

What is Action Region in Salesforce?

Action Region 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?

View state 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 JavaScript 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 its edited.

What is the advantage of using custom settings?

You don't 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 visualforce 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.

Can ‘set’ store duplicate values in it?

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

Can two users have same profiles?


How can you refresh a particular section of a visualforce 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 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 custom label; in visualforce 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 relationship 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 trigger.New in trigger ?

Trigger.New is a list of records that are in the context of trigger or becuase of these records(modification,Creation, deletion) the trigger has been called.

How do we bulkify the trigger ?

Bulkfication requires iterating over all the records in trigger context\nfor example : for(account ac:\n{\n// your logic here\n}.

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 ?

Trigger.New 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 component 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 standard controller 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 ?

string.valueof(integerName); .

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

delete 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 in recycle bin .

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 initialized 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.

Consider that a record meets a workflow criteria for time based workflow action, the action goes in queue. Later, before the time based action is triggered, the same record gets modified and the criteria previously met is changed and now it does not meet the workflow criteria, what happens to the time based action placed in queue?

The time based workflow action is removed from the queue and will not get fired.

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 is not 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 integer.

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 governors limit in Salesforce?

Governors limit are run time limits that are enforced by Salesforce. Governors 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 Organization 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.

Admin What is outbound message in Salesforce?

Outbound messaging is part of the workflow rule functionality in Salesforce. Workflow rules watch for specific kinds of field changes and trigger automatic Salesforce actions, such as sending email alerts, creating task records, or sending an outbound message.

What are Salesforce 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. 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.

Why we use record types in Salesforce?

record types is to create a different page layout for different records within the same object. Each record type has their own values available for a picklist on the object, this is really where the different business process comes into play and is really useful.

What are custom labels in Salesforce?

We can use System.Label.labelName to access custom label in apex code. 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.

What is Flow interview in Salesforce?

A flow interview is a running instance of a flow. A flow is an application built by your administrator that asks you for inputs and does something in Salesforce based on those inputs.

what is difference between Master Detail relationship Vs Look up relationship ?

Master Detail relationship is the Parent child relationship. In which Master represents Parent and detail represents Child. If Parent is deleted then Child also gets deleted. Rollup summary fields can only be created on Master records which will calculate the SUM, AVG, MIN of the Child records. Look up relationship is something like as-a (Containership) relationship. Where one record has reference to other records. When one record is deleted then there is no impact on other records.

What is Accounts ?

Accounts are companies which your doing business.

What is difference between Personal Accounts and business Accounts ?

Personal Accounts are solo person or an individual customer doing business and Business Account is company or an organization.

What are the different workflow actions available in workflows?

They are Field update, Email alert, Send Outbound messages, Create new task.

What is whoid and whatid in activities?

Whoid is the id of either contact or Lead. Whatid is the id of the related to record in activity record(standard or custom object) .

What is the difference between and is PAAS(platform as a service) and is SAAS(software as a service) .

What is a externalid in Salesforce?

It is a field which can be used to store a value that is used as a reference for that record in other system. For example if you have a record in system ‘xyz’ where it is referenced by some value then that value can be used as external id in Salesforce for that record.External id can be used for upsert operation in data loader.

What happens upon lead conversion ?

When lead is converted a contact, account and optionally an opportunity is created.

How can you create a many to many relationship in Salesforce?

This can be done by creating junction object between the two objects.

What happens to detail record when a master record is deleted?

detail record gets deleted.

What happens to child record when a parent record is deleted(look up relationship)?

Child record remains undeleted.

Can you see a lead which is converted in Salesforce UI?

The detail record is not seen. But a page, wherein it shows the links for formed account, contact and opportunity.

What various default accesses are available in OWD?

Private, Public Read only, Public read write, Public read write transfer, controlled by parent, Public full access.

Can a user not have a role?

Yes, this is possible, Role is not mandatory for user.

Can a user not have a profile?

No, a user should always have a profile. Profile is mandatory unlike role.

What is Profile?

Profile contains set of permissions and access settings that controls what user can do within the organization.

What are permission sets?

A set of permissions is given to the users without changing the profile.

What is OWD?

OWD’S are base line record level security for objects in the organization. It is used to restrict access to data

What is Roles?

A role controls the level of visibility that users have to an organization’s data

What is User?

The people who have authenticated username and password to login to the Salesforce successfully.

What is Sharing Rules?

These are used to override the OWD permissions. Sharing rules are two types, They are Based on record owner and Based on criteria.

What is the role hierarchy?

Role Hierarchy states that higher hierarchy person can see lower hierarchy person records.

Can you override profile permissions with permission sets(i have defined some permissions in profile am trying to use permission sets for the same object, can i override permissions for a particular object in the permission sets over to the profile?

No. Permission Sets are used only to extend the Profile permissions. It never overrides.

I want to have read/write permission for User and read only for User , how can you achieve?

Create a Permission Set with read/write and assign it to User .

I have an OWD which is read only, how all can access my data and I want to give read write access for a particular record to them, how can i do that?

All users can just Read the record. Create a Sharing Rule to give Read/Write access with “Based on criteria” Sharing Rules.

What is the difference between role hierarchy and sharing rules? will both do the same permissions?

Role Hierarchy states that higher hierarchy person can see lower hierarchy person records. Sharing Rule is used to extend Role Hierarchy.

Is it possible to delete the user in Salesforce?

No, once we create an user in Salesforce we cannot delete the user record. We can only deactivate the user record.

How to provide security for Meta-Data files (Schema)?

Using Profiles and Permission Sets .

How to give permissions to two fields for different users who belongs to different profiles?

Permission set.

What is Grant Access Using Hierarchies?

In OWD we have Private but your higher position persons should see that time we go for Grant Access Using Hierarchies.

How we can change the Grant access using role hierarchy for standard objects?

Not possible.

What is manual sharing?

Manual sharing is to share a record to a particular user manually. Go to detail page of record and click on manual sharing button and assign that record to other user with Read or Read/Write access. Manual Sharing button enables only when OWD is private to that object.

What are the record types?

Using record types we can assign different page layouts to different users based on their profiles and To enable different sets of standard/custom picklist values to different users.

Why we are using data loader?

through import wizard we can import up to 50,000 records if we want to insert more than 50,000 records then we use data loader. through data loader we can import upto 1 million records. using import wizard we do only insert, upsert but using data loader we do insert, update, upsert, export, export all ,delete.

Keep Visiting us !! we will update more questions..