Salesforce Technical Questions with Answers -1

  • Salesforce Interview Questions

In this series of blogs and articles, Cloudely experts present you the Salesforce interview questions and answers, real-time scenarios, use cases, errors, turnarounds and more. This article is the first of this series. We hope you will find it helpful.

1)  Use Case: How to Lock the records which are queried through Apex?

Using the FOR UPDATE keyword, we can lock the rows fetched by SOQL query. We can overcome the following errors like (UNABLE TO LOCK ROW and UNABLE TO OBTAIN EXCLUSIVE ACCESS OF THIS RECORD.) When there are two/more processes updating the same record at the same time, we will face these errors.

[SELECT Id,Name from Opportunity FOR UPDATE ];

2) Error: You have reached the maximum number of 15 object references on ObjectName. You must remove at least 1 relationship(s) in order to save this Formula Field. – How to overcome this error?

This error occurs due to using more than 15 cross object references in Formula fields, Workflow Rules and Field Updates, Approval Processes, Validation Rules, Assignment Rules, Escalation Rules, Auto-Response Rules on a single object.


Create a flow/Process Builder and write a formula you want, to update a field on that specific object.

3) ERROR : Compiled formula is too big to execute. Maximum size is 5,000 characters.

When you use formula fields to calculate another formula, it will consider both fields into character limits. So, if we use a complex formula or nested formulas you might get this error.

Workaround: Move your entire formula into a flow/Process builder, calculate the values over there and load the value into another field(this is a new field you need to create based on the return type of your formula). Then update the record.

4) Case: when a user creates any opportunity, it is redirecting him/her to the product selection screen. Why?

Possibility: Prompt users to add products to opportunities this setting may be enabled.

To disable it , go to setup -> search for Opportunity settings in quick find → uncheck the checkbox for “Prompt users to add products to opportunities”.

Suggested Reading: Salesforce Interview Questions Series 1

5) How to avoid nested iterations?

We can use map collections to avoid writing loop inside loop. This will decrease the execution time.


for(Account Acc: [select id,acountcustomfield__c from account]){

for(contact con: [select id,contactcustomfield__c from contact where AccountId ]){

if(con.contactcustomfield__c != acc.accountcustomfield__c){

Delete con;




To avoid nested iterations, we can use map as shown below:

MAP<id,account> accmap= new map<id,account>();

for(Account Acc: [select id,acountcustomfield__c from account]){



for(contact con: [select id,accountID,contactcustomfield__c from contact where AccountId =:accmap.keyset()]){

if(con.contactcustomfield__c !=  accmap.get(con.accountID).contactcustomfield__c){

Delete con;



6) Why do we need Salesforce CPQ ?

CPQ stands for Configure, Price, Quote.  If you want to generate an accurate quote/ proposal and get approvals in a very fast manner in the competitive world, CRM alone could not make it.

Salesforce CPQ will allow you to avoid manual errors and fasten the process of generating quotes. Not only the quote generation, from Quote to Cash the entire process we can achieve through Salesforce CPQ and Billing.

Guided upsell and cross sell increase additional revenue, automated proposal and contract generation improves sales rep productivity and product validations will decrease the  orders rejection in some cases and boosts the customer satisfaction.

You can maintain and monitor your data all at one place like customers, Opportunities, Quotes, Orders, Approvals and Payments.

7) As a Salesforce Admin/Developer, why do we learn Salesforce CPQ?

Salesforce CPQ is very developer friendly. We can configure products, pricing and documents with some clicks. We can achieve 80% of the requirements with out of the box features in Salesforce CPQ.

On other hand, Salesforce CPQ has 9.53% market share and 2486 customers. It is in the top 3 in competition in the CPQ segment.

Suggested Reading: Salesforce Technical Questions and Answers

8) What is the twin field concept?

When Custom fields of two different Objects are editable and have the same API name and Data type we call these fields as “twin fields”. Values pass from object A to object B when object B record is created.

Objects which are supported for twin fields are given in the below table. Object A values can be passed to Object B.

Object A Object B
Contract Opportunity
Service Contract Opportunity
Opportunity Products Quote Line
Product Quote Line
Product Option Quote Line
Quote Order
Quote Line Order Product, Opportunity Product, Subscription, Assets, Contract Line Item
Subscriptions Quote Line
Contract Line Item Quote Line
Asset Quote Line
Order Product Invoice Line

8) How to control the quantity scale(decimal places of quantity) in Salesforce CPQ?

Setup → Installed Packages → Click on “configure” next to Salesforce CPQ package → Click on Additional Settings Tab → Quantity Scale(give a number based on your requirement)

9) What are custom scripts in Salesforce CPQ?

To add additional functionality to CPQ Quote line Editor we can use custom scripts(Javascript). These are called by Quote Calculator plugins.

Default Methods: isFieldEditable, isFieldVisible etc.

10) What is a co-terminated subscription in Salesforce?

Co-terming in quotes means termination of contracts. Fields such as Contract Co-Termination(SBQQ__ContractCoTermination__c) determine how Salesforce CPQ co-terminates contracts for this customer.

  • If you select Always, you can pick whether Salesforce CPQ always co-terminates contracts for renewal opportunities or for add-on opportunities.
  • If you select Prompt, Salesforce CPQ co-terminates only for add-on opportunities.

11) What is block pricing in Salesforce CPQ?

We can price a product based on quantity ranges. This is called block pricing.

When a sales rep adds that product to a quote, Salesforce CPQ checks where it falls in the quantity ranges and prices the quote line accordingly.

Fields in Block pricing:

Lower Bound: 

The lowest quantity for this quantity range.

Upper Bound:

The highest quantity for this quantity range. This value isn’t included in the range. EX: If you want to set an price 1 to 10 quantity range, your lower bound should be 1 and upper bound should be 11.

Your next range should be starts with 11(lower bound).


The price for this quantity range.

12) What are bounded and unbounded queries in salesforce?

  • Bounded Queries – Where we have a well-defined set of fields, for example, all standard fields.
  • Unbounded Queries – Where we have a set of fields that are not predetermined, for example, all fields or all custom fields.

13) How to overcome the error below?


FIELDS(CUSTOM) and FIELDS(ALL) are considered unbounded.

Below table shows the support for FIELDS() in bounded and unbounded queries:

Approach Bounded – FIELDS(STANDARD) Unbounded – FIELDS(ALL) and FIELDS(CUSTOM)
Apex (inline and dynamic) Supported Not supported
Bulk API 2.0 Supported Not supported
CLI Supported Supported only if the result rows are limited.
SOAP API and REST API Supported Supported only if the result rows are limited.


public class ApexUtility {

public static String AllFields(String ObjectName) {

List<String> fields = new List<String>(Schema.getGlobalDescribe().get(ObjectName).getDescribe().fields.getMap().keySet());

String query  = ‘SELECT ‘+String.join(fields, ‘,’)+’ FROM ‘+ObjectName;

return query;



for(Account acc: Database.query(ApexUtility.allFields(‘Account’)) ) {



14) How to disable the CPQ triggers in APEX?

ANS:  SBQQ.TriggerControl.disable();(This statement disable only CPQ triggers)

SBQQ.TriggerControl.enable();(This statement helps to enable cpq triggers)

SBQQ.TriggerControl.isEnabled();(This statements returns true if CPQ triggers are enabled)



try {

// Do something simple and interesting without

// running triggers.

quote.MyStatus__c = ‘Red’;

update quote;

} finally {




15) Error: List index out of bounds: [n]

Cause: when we try to access an element inside the list with an index which does not exist in that list then we will get this error.

Ex: List<integer>  scores =new list<Integer>();


System.debug(scores[1]);//(This statement will throw an error because the index number of “78” is 0 but we are trying to access it with 1)

So, if you are accessing indices you do expect to exist, check out the lists themselves. They may be empty or they may not have the correct number of elements in them, for various reasons. You can also use the list method list.size() to determine how many indices are in the list itself.

16) How to stop a piece of code from executing when it is invoked from Test classes?

Ans: Test.isRunningTest() Returns true if the currently executing code was called by code contained in a test method, false otherwise. Use this method if you need to run different code depending on whether it was being called from a test.

EX: if(!Test.isRunningTest()){

//do something


Source :

Learn Salesforce with Cloudely

Learning and getting certified in Salesforce would be a great addition to your skills and profile. You can attract better opportunities when you are in the market because of its demand and growth for Salesforce.

Enroll in our online Salesforce training programs.

Found this article informative? Share this article.

Looking for expert answers to Salesforce questions? Send them to Our Salesforce experts will answer your queries.

Gopi Dammalapati is Senior Salesforce Developer and Technical Mentor at Cloudely Inc. His areas of specialization include Apex and CPQ implementation. He has a great passion in mentoring budding Salesforce enthusiasts. You can connect with him on LinkedIn and Trailhead.

By |2023-02-24T14:19:15+05:30January 5th, 2023|Comments Off on Salesforce Technical Questions with Answers -1