Salesforce Interview Questions-Unlocked
Salesforce Interview Questions-Unlocked
Interview questions
10. Nimble
It makes tremendous sense to make use of the centralized server of the provider
of cloud computing services as not only does it reduce the costs by a great extent
by making redundant the need to buy several software licenses, it also eliminates the
huge costs required by an organization to maintain and upgrade existing software.
Read more on Cloud Computing Advantages :- Cloud Computing Advantages.
5. What is the definition of CRM?
“Cloud Computing definition given by NIST (US National Institute of
Standards and Technology) : Cloud Computing is a model for enabling
ubiquitous, convenient, on-demand network access to a shared pool of
configurable computing resources that can be rapidly provisioned and
released with minimal management effort or service provider interaction“.
6.What are deployment modes of cloud computing?
Cloud computing services can be provided in four different deployment modes
depending on size and structure of an organization. Four deployment modes
of cloud computing are
1. Public Cloud.
2. Private Cloud.
3. Hybrid Cloud and
4. Community Cloud.
7. What is PaaS?
PaaS means” Platform as a Service”. Here in “PaaS “ the cloud service
providers provides hardware, OS(operating System), Storage, Network
services over the cloud. It is the way like a rent. If there is no service like
Platform and there will be no Applications. Which applications are build on a
Platform.
Get more details on Paas :- What is PaaS.
8. What is SaaS?
SaaS means Software as a Service. Through this Services all the software’s
are distributes over the cloud. By using SaaS no need to install any software
73. How can you change the setting “Grant Access Using Hierarchies”
for Standard Objects ?
2) Types of cloud?
3) what is crm?
4) crm providers?
Ans:
• Salesforce
• FreshWorks
• Keap
• monday.com
• Zoho CRM
• Oracle NetSuite CRM
• Hubspot CRM
• Pipedrive CRM
• Quickbase
• Zendesk
• Sage CRM
• SugarCRM
• Insightly
Ans : Due to the nature of multitenancy and the fact we are sharing
resources, governor limits are in place to ensure that any
Apex we develop, does not monopolize the shared resources we
are allocated.
9)what is
org?
Ans: A tab is like a user interface that is used to build records for objects and
to view the records in the objects. There are three types of tabs in
Salesforce: Custom object tab. Web tab.
Ans: Objects are database tables that allow us to store data specific to the
organization in salesforce. Two type of objects in Salesforce. They are. 1. ...
Examples of standard objects are accounts, contacts, opportunities, Leads,
products, campaigns, cases, users, contracts, Report, and dashboards, etc.
Ans: A field is like a custom Database column. Object field Store the data for
our records. Salesforce by default provide few fields with salesforce standard
objects those are called standard fields. We cannot
delete salesforce standard field.
Ans: Picklist: Only one value at a time. Sometimes that's a good thing. Multi-
Select Picklist: One or more values at a time.
1. Lookup Relationship
2. Master Details Relationship
3. External Relationship
4. Self-Relationship
5. Role Hierarchy Relationship
6. Many to Many Relationship
Ans:
Role Profile
A profile sets the limit of what a user
The role helps in defining data visibility
can do in the organization
A role defines what user data a user
Profile defines permissions
can see based on hierarchy
Defining role to a user is mandatory
Defining profile is not always mandatory
always
Profiles assist to decide record privileges
Hence, Roles offer a feature to control
i.e. assuming the User can observe the
access to records by impacting
record, it concludes what the User can
reports. For example, filtering “My
function, delete, edit, view on that
Teams”. Roles function if an
record. Most of the time it controls other
organization’s security model (OWDs)
system privileges like export data, mass
is set to private.
email, and many more.
Ans: A user is anyone who logs in to Salesforce. Users are employees at your
company, such as sales reps, managers, and IT specialists, who need access
to the company's records. Every user in Salesforce has a user account.
Ans: A role hierarchy works together with sharing settings to determine the
levels of access users have to your Salesforce data. Users can access the
data of all the users directly below them in the hierarchy. ... Each role in
the hierarchy just represents a level of data access that a user or group of
users needs.
Ans:
Ans: A report is a list of records that meet the criteria you define. It's
displayed in Salesforce in rows and columns, and can be filtered, grouped, or
displayed in a graphical chart. Every report is stored in a folder. Folders can
be public, hidden, or shared, and can be set to read-only or read/write.
Ans; The four types of Salesforce reports are Tabular, Matrix, Summary, and
Joined. They will allow your Salesforce administrator to pull, send, and review
the data in your Salesforce account in different formats.
Ans: Validation rules in Salesforce verify the data a user enters in a record.
The data should meet the standards specified by the organization. It can
contain a formula or expression that evaluates the data in one or more fields
& returns a value true or false
Ans: A sandbox is simply a copy of your database you can use to test new
ideas
Ans: In Salesforce Classic, you can create four different types of email
templates: text, HTML with Classic Letterhead, custom, and Visualforce. All of
these email templates can include text, merge fields, and attached files.
and Workflow?
4. What Are The Different Ajax Action Tags? What Does Each Do?
Ans-
actionPoller It is used to call method of the apex controller after some time interval. It take time
interval in seconds. Example : To check latest commission of the manager.
actionFunction It is used to call apex controller method from Javascript function using ajax request.
actionStatus It is used to display start and stop statuses of AJAX requests.
actionRegion It is used to refresh a particular region of the visualfoce page in the ajax request.
There are three types of controllers. They are, Standard Controller, Custom controller & Controller extensions.
It is used to hide or show a particular component. Rerender is used to refresh a particular section of the
visualforce page. We have to just mention the id of
Rendered is bound to a Boolean variable in controller the page section (in the Rerender attribute) that
which can be switched between true and false making needs to be refreshed.
the vf component display or hide depending on
Boolean value.
A quick solution would be to place the dml operations in a single method that you call from the page action
parameter.
pageController{ private
boolean doDML;
//constructor
public pageController(){
if(logic = true){
doDML= true;
}
if(doDML){
//run DML statements
}
return null;
}
}
}
13. If there are three controller extensions in a visualforce page. All three extensions contains Save method.
Save method of which class will get called from visualforce page on save action.
Ans-It will call save method of first extension (left extension).
When view state crosses the limit of 170 KB, view state error occurs.
16. What Are the Effects Of Using The Transient Key Word?
Ans-
The transient key word prevents the data from being saved into the view state. This should be used for very
temporary variables.
DataTable-
Data can be displayed using the custom style sheets(CSS).
Column headers need to be specified explicitly.
No need to specify within the Pageblock or Pageblocksection.
defining this controller is similar to standard controller. But need to add one more attribute recordSetVar
1. From the setup menu go to Setup-> develop -> Build->Pages-> click on new button to create a page & enter
name & code for visualforce page.
2. From the Visualforce editor. Enter /apex/pagename at the url & create a new page in the visualforce editor.
<apex:page>
</apex:page>
To enable this, go to user details page check the development mode check box.
26. When Do You Need To Go Beyond A Standard Controller And Code Custom Apex?
Ans-
If you need data beyond the limits of what is available in the standard controller or actions that go beyond the
provided standard actions.
28. What Are Some Apex Classes That Are Commonly Used Within Controllers?
Ans-
StandardController, SelectOption, PageReference, Message, etc.
29. Is It Always Necessary To Know Apex To Create Visualforce Pages? When Does It Become Necessary?
Ans-
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.
For example, there is a wrapper class that can access the account records and display an in-page block table.
You have an option of a checkbox, and you can associate multiple serial numbers to display the number of
records. So, there can be multiple records and respective serial numbers.
Example:
Visualforce Component Name – VFCompo1
<apex:component >
<apex:attribute name="textValue" description="This is the value for the component" type="String"
required="true"/>
<apex:attribute name="textColor" description="This is color for the border." type="String" required="true"/>
<apex:outputText value="{!textValue}" style="color:{!textColor};"/>
</apex:component>
<apex:page tabStyle="Account">
<apex:pageBlock >
<apex:pageBlockSection title="myComponent Test" collapsible="false">
<c: VFCompo1 textValue="This Text is blue" textColor="blue" />
<c: VFCompo1 textValue="But this is red" textColor="red" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Triggers in Salesforce
[1] What is Trigger in Salesforce?
Ans: The trigger is piece of code that executes before or after event on the
following operations such as insert, update, delete, undelete etc. trigger enables
to perform custom actions before and after modifications to the records of
Salesforce.
Example:
trigger prefixName on Account (before Insert, before Update){
}
• Trigger.isDelete: Returns true if this trigger was fired due to a delete operation,
from the Salesforce user interface, Apex, or the API.
• Trigger.isAfter: Returns true if this trigger was fired after all records were saved.
• Trigger.isUndelete: Returns true if this trigger was fired after a record is
recovered from the Recycle Bin (that is, after an undelete operation from the
Salesforce user interface, Apex, or the API.)
• Trigger.new: Returns a list of the new versions of the sObject records. This
sObject list is only available in insert, update, and undelete triggers, and the
records can only be modified in before triggers.
• Trigger.newMap: A map of IDs to the new versions of the sObject records. This
map is only available in before update, after insert, after update, and after undelete
triggers.
• Trigger.old : Returns a list of the old versions of the sObject records. This
sObject list is only available in update and delete triggers.
• Trigger.oldMap: A map of IDs to the old versions of the sObject records. This
map is only available in update and delete triggers.
• Trigger.size: The total number of records in a trigger invocation, both old and
new.
• You can use an object to change its own field values using trigger.new, but only
in before triggers. In all after triggers, trigger.new is not saved, so a runtime
exception is thrown.
2) Logic-less Triggers
If you write methods in your Triggers, those can’t be exposed for test purposes.
You also can’t expose logic to
be re-used anywhere else in your org.
Scenario 1 : When we are trying to insert new record into object. If there is any
record existing with same account name it should prevent duplicate record.
Scenario 2: Write a trigger to prefix Account Name with ‘Mr’ when new record
is inserted.
Scenario 3: Whenever a new record is created into account object . Before this
new record is inserted into
Account, delete all the contacts records with this account name.
Scenario 7: To update the owner of a case based on the values selected within a
picklist and populate the owner field with the created by field data. When we have
selected any Field name=Status
Picklist Values= priced-(Initial) Priced-(Re-priced) Price(File Loaded)
Scenario 8: Write a trigger that will prevent a user from creating a lead that
already exists as a contact. We will use the lead /contact email address to detect
duplicates.
Lead is created or updated.
1. Lead has an email address.
2. 2. Try to find a matching contact based on email address.(Using SOQL)
3. If a match is found give an error
4. If a match is not found do nothing.
Scenario 9: When we are trying to delete customer record delete all the
corresponding child records from test object, where customer is lookup field in
the object.
Scenario 10: When we create the opportunity with probability =50% then the
opportunity owner will be automatically added to Account Team of the associated
account for the opportunity.
Scenario 11: Invoking the apex class from the trigger. Whenevr new customers
record is created /updated then income tax should be calculated based on salary
and should be updated to field income tax (Currency field).
Scenario 12: If we delete any of the existing customer record then first create new
test object record with customer record values then delete customer record.
Scenario 13: Whenever we try to update the phone of account record then update
the related contact phone number with the new Account phone number before
account record is updated.
When we delete the account record then delete the corresponding contact records.
Scenario 16: Create ‘Sales Rep’ field with datatype (Text) on the account
object. When we create account record, the account owner will be
automatically added to Sales Rep field. When we update the Account
owner of the record, then also the Sales Rep Will be automatically
updated.
The execution logic of the batch class is called once for each batch of records. The default batch size is 200
records.
You can also specify a custom batch size. Furthermore, each batch execution is considered a discrete
transaction.
With each new batch of records, a new set of governor limits is in effect. In this way, it’s easier to ensure that
your code stays within the governor execution limits.
Another benefit of discrete batch transactions is to allow for partial processing of a batch of records in case
one batch fails to process successfully, all other batch transactions aren’t affected and aren’t rolled back if they
were processed successfully.
Execute:
global void execute(Database.BatchableContext bc,List <p>){}
Finish:
global void finish(Database.BatchableContext bc) {}
[11] What is the maximum size of the batch and minimum size of the batch ?
Ans: The default batch size is 200 records. Min=01, max=2000
[13] How to track the details of the current running Batch using BatchableContext?
Ans: You can check the AsyncApexJob.Status using the JobId from the Database.BatchableContext.
Database.Insert
If we use DML database method (Database.insert) to insert/update record in bulk, then if error occurs the
remaining records will be inserted/updated means partially operation will be done.
But
if you use Database.insert(list, false) It will insert 2 records successfully and rest 2 records (required fields
missing) will not be inserted.
Database.insert(list, false) In this scenario you will not get any exception
[24] If I am inserting two record of the Account. I want a list of successful and failure records, how to
do that.
Ans:
[27] Write a batch apex class to prefix Mr or Ms. as per Gender of the existing customer record (05 Lac).
Show successful and failure customer Ids.
0 0 5 ? * 1,2,3,4,5,6,7
{1} {2} {3} {4} {5} {6}
{4} Day_of_month - ? means no specific value, only available for day of the month and day of the week.
{5} Month - * indicates all values, i.e. every month. (if we only want to run on 1st Jan say, this would be 1)
{6} Day_of_week - 1,2,3,4,5,6,7 here specifies days 1,2,3,4,5,6,7 in the week. We could also write this string as
MON-FRI or preferably as * to indicate all values.
So this job reads to run at "0 seconds past 0 minutes of the 5th hour on no specified day of the month for
every month of the year for every day of the week".
[31] What will be con object expression, if I want to schedule an apex class on 15th May 2020 at 03:00 PM.
Ans : String cronExp ='0 0 15 15 5 ? 2020'
[] What will be con object expression, if I want to schedule an apex class on 01st DAY of every month
at12:00 AM.
Ans: String cronExp ='0 0 0 1 * ? *';
[33] From where to see scheduled apex job and delete a scheduled job
Ans: Scheduled Jobs
[39] Is there is any way through which we can call future method from batch apex?
Ans: As we know that a webservice can be called from batch class and webservice can call @future method. So
in your batch class call webservice and which can call your @future method.
Also you can call future method from finish method in batch class.
[40] What all different things which we need to consider while using future methods?
Ans:
1. Methods with the future annotation cannot be used in Visualforce controllers in either
getMethodName or setMethodName methods, nor in the constructor.
2. You cannot call a method annotated with future from a method that also has the future
annotation. Nor can you call a trigger from an annotated method that calls another annotated method.
3. Future methods cannot be called from batch class.
[41] Can we modify the scheduler class or classes referenced by this scheduler class if any scheduled job is
pending?
Ans: No
If there are one or more active scheduled jobs for an Apex class, you cannot update the class or any classes
referenced by this class through the Salesforce user interface. However, you can enable deployments to
update the class with active scheduled jobs by using the Metadata API.
[42] What we can do if we have to deploy the scheduler class or classes referenced by this scheduler class if
any scheduled job is pending for that scheduler class in target org?
Ans: By default, changes to Apex code that have Apex jobs pending or in progress can’t be deployed. To deploy
these changes, do one of the following.
• Cancel Apex jobs before deploying changes to Apex code. Reschedule the jobs after
the deployment.
• Enable deployments with Apex jobs in the Salesforce user interface in the Deployment Settings page.
Callouts include HTTP requests as well as methods defined with the webService keyword.
1. What is an apex Unit Testing Or what is a test class? Why we need to write Test classes?
Ans: A test class is a class which helps in checking the quality of code before it can be deployed to Salesforce
Production. It helps in code coverage of an Apex class or Trigger.
Exampl
e:
@isTe
st
private class MixedDML
{
static testMethod void mixedDMLExample()
{ User u;
Account a;
User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
// Insert account as current user
System.runAs (thisUser) {
Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
UserRole r = [SELECT Id FROM UserRole WHERE Name='COO'];
u = new User(alias = 'jsmith', email='[email protected]',
emailencodingkey='UTF-8', lastname='Smith',
languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id, userroleid = r.Id,
timezonesidkey='America/Los_Angeles', username='[email protected]');
insert u;
a = new Account(name='Acme');
insert a;
}
}
}
@isTest
public class UserAndContactTest {
public testmethod static void testUserAndContact() {
InsertFutureUser.insertUser();
Contact currentContact = new Contact(
firstName = String.valueOf(System.currentTimeMillis()),
lastName = 'Contact');
insert(currentContact);
You can use runAs only in test methods. The original system context is started again after all runAs test
methods complete. The runAs method ignores user license limits. You can create new users with runAs
even if your organization has no additional user licenses.
Enabling this attribute exposes the data from the database to the test
class.
It is recommended not to use as the code coverage of you apex class or trigger will now be dependent on
the data which is present in org and depending upon that the code coverage may change.
But some objects we can't create a data for testing. for example Profiles. we can't create profiles in test
classes. so we will query the profiles and assign to users.
@isTest (SeeAllData =
true)
Minimum code coverage for the trigger is at least 1% and for class, the overall code coverage of
Test utility classes/TestDataFactory contain methods that can be called by test methods to perform useful tasks,
such as setting up test data.
1. Single
Records:
This includes testing to verify that a single record produces the correct,
expected result
2. Bulk
Records:
Any apex code, whether a triggers, a class or on extension may be
used
for 1to 200 records we must test not only the single record case, but the
bulk cases as well.
3. Positive
scenarios:
This type of component testing expect a system to save a record without
error.
4. Negative
scenarios:
This type of component testing expect a system to give error.
5. Restricted User:
Test whether a user with restricted access to the objects used in code sees the
expected behavior, i.e whether they can run the code or receive error messages.
Note: Comments blank lines,System.debug() statements and curly brackets are excluded.
Multiple statements on one line are counted as one line for the purpose of code coverage.
Example :
22. Does Salesforce count calls to system.debug() against the code coverage?
Ans: No, Salesforce does not count it against the code coverage.
ApexCodeCoverageAggregate:
It stores the sum of covered lines for a class after checking all test methods that test it
ApexCodeCoverage:
Stores the lines that are covered and uncovered by each individual test method.
29. Can we use (SeeAllData=true) and (isParallel=true) in same apex test method?
Ans: @isTest(SeeAllData=true) and @isTest(isParallel=true) annotations cannot be used together on the
same Apex test method.
Example:
Performing web service callouts in Apex are not supported within Test Code. Hence we could use the
Test.isRunningTest() to conditionally identify and route the execution of a code block that calls the Test
Mock framework to simulate a mock, callout response.
When we are setting up test data from Apex test method, we need a way to disable the triggers that will fire. It
might cause “LimitException: “Too many SOQL queries: 101″. In this case, the triggers are not the target of the
test case, hence this scenario will cause the test method to fail. It is not necessary to disable the trigger for
every test case, instead we can use isRunningTest().
Setup up the trigger by leveraging isRunningTest(). isRunningTest() – Returns true, if the currently executing
code was called by code contained in a test method, false otherwise. Use this method if we need to run
different code depending on whether it was being called from a test.
2. Testing callouts – in our callout code we check to see if we‘re executing within a unit test context by
checking Test.isRunningTest() and instead of getting your callout response from an HttpResponse.send()
request, you return a pre-built test string instead.
When we create an Apex class from a WSDL, the methods in the auto-generated class call
WebServiceCallout.invoke, which performs the callout to the external service. When testing these methods, we
can instruct the Apex runtime to generate a fake response whenever WebServiceCallout.invoke is called. To
do so, implement the WebServiceMock interface and specify a fake response for the Apex runtime to send
4. So, if your team uses a common sandbox for development purpose, then what if two or
more members wants to work on same visualforce page.
Ans- Team lead handles this situation to which developer will work on which component. And
all the developer has updates of development on a sheet or outlook.
It needs to be done first in Developer edition or testing org or in Sandbox org. Then, to deploy
it in production, a user with Author Apex permission must deploy the triggers and classes using
deployment tools.
However, Visualforce pages can be created and edited in both sandbox and in production.
Only if the page has to do something unique (different values), it would have to be developed
via Sandbox.
A. Change Sets
B. Eclipse with Force.com IDE
C. Force.com Migration Tool – ANT/Java based
D. Salesforce Package
An inbound changeset is a change set created to receive the component from outbound
changeset. An Inbound changeset created on destination org side.
12. I have created a new outbound changeset but not able to deploy in another sandbox or
production (option is not available). What should I do?
Ans- Go to destination org -> Deployment Setting -> Select org -> Allow Inbound Changes
13. Difference between Run local test and run all test.
Ans- Run local tests - All tests in your organization are run, except the ones that originate from
installed managed packages. This test level is the default for production deployments that
include Apex classes or triggers.
Run all tests - All tests in your organization are run, including tests of managed packages.
14. My first outbound changeset failed. Now I want to add dependent component in the
existing changeset. How can we do it.
Ans- Clone first outbound changeset and then add more components.
17. Have younever deployed any component from developer sandbox to production?
Ans – No, there was a special deployment team to handle this. Development team creates a
outbound changeset and tells us to add our component in it. (You can give answer according to
your understanding).