Tuesday, 29 August 2017

Salesforce Interview Questions -Venolearn(A Unit of Venolin Technology Pvt Ltd)


                             Salesforce Interview Questions on DML

 1)How many types of DML statements does Salesforce supports?

 A. There are altogether 6 types of statements:
  1. Insert
  2. Delete
  3. Update
  4. Merge
  5. Undelete
  6. Upsert
2) How many DML statements are allowed in on transactions?
A. Salesforce allows 150 DML statements per transaction.
3)What is difference between insert and Database.insert()?
A. The main difference between them is that Database.insert, lets one process partial record processing if an error is encountered during the processing of bulk records.
4)How to undelete a record from recycle bin with the help of DML?
A. For this to work records should be deleted and present in the recycle bin:
For eg : List<contacts> cons= [select id from contact where isDelete = true ALL ROWS];
Undelete cons;
5) What happens to the child record when we merge two records?
A. You can merge max 3 records in one time and Salesforce deletes the other records and reparent the child records.

                             Salesforce interview Questions SOQL

6) What is SOQL?
A. It stands for Salesforce Object Query Language.
7)How many SOQL we can perform per transaction?
A. We can perform 100 SOQL statements per transactions.
8)How can we fetch top 5 opportunity according to the amount?
A. Select Name, id from opportunity order by desc amount limit 5.
9)How many records can we fetch using one SOQL query?
A. We can get upto 50000 rows of records per SOQL query.
10)How can we fetch related contact records by querying on Account object?
A. We would have to use inner query to fetch all the child records using their relationship name.
Select Name, id, (select name from contacts) from account.
11) What is SOSL?
A. It stands for Salesforce Object search language.
12) How SOSL is different from SOQL?
A. We can search for a value in more than one object in one SOSL query. Its syntax is also different with respect to SOQL. We can only perform 20 SOSL per transaction and we can only see 2000 rows of returned records.
13) How to use filter on Name field if only partial string value is known?
A. SELECT Name, id FROM Account WHERE Name LIKE ‘Z%’
16)What is the correct way to use date in where clause?
A. For this we need to make sure that the field we are using in where clause is of type Date or DateTime as syntax for both are different.
For DateTime: SELECT Name, id FROM contact WHERE CreatedDate > 2017-08-29T10:00:00-08:00
For Date : SELECT Name, id FROM contact WHERE CreatedDate > 2017-08-29
17)How to filter Boolean field in SOQL?
A. The syntax of where clause would be something like this: ’ Where BolleanFieldName = True ‘
18) How to use Multi Select picklist as a filter while fetching data using SOQL?
A. For Exact match of ABC and EFG below statement is used
SELECT Id, Name, FieldNameMultiSelectPl__C FROM CustomObjectName__c WHERE FieldNameMultiSelectPl__C = ‘ABC;EFG’
Or for multiple values.
SELECT Id, Name, FieldNameMultiSelectPl__C FROM CustomObjectName__c WHERE FieldNameMultiSelectPl__C includes (‘ABC;EFG’ ,’CDE’  )

19) How many characters are allowed in a where clause?
A. We are allowed to use maximum of 4000 characters in a where clause per SOQL.
20)What are the considerations for using Group by clause?
A. There are some fields on Object which are not supported in grouping.
If a query includes Group by clause then it cannot be used with queryMore() method.
Relationship queries cannot be used in conjunction with Group By clause.

                                    Salesforce Interview Questions on Trigger
 21)What is a Trigger?
Trigger can invoke Apex code, they come in handy when we want to perform some custom task just before or after a record is either created updated or deleted.
22)What are the various event on which a trigger can fire?
A trigger is a set of statement which can be executed on the following events:
  1. Undelete
  2. Update
  3. Merge
  4. Delete
  5. Upsert
  6. Insert
23) Broadly classify the Trigger?
Triggers can be broadly classified as before or after Trigger.
  • Before triggers are used to perform a task before a record is inserted or updated or deleted.
  • After triggers are used if we want to use the information set by Salesforce system and to make changes in the other records
24)What are the considerations while implementing the Triggers?
Consider the following before implementing the triggers.
  • Upsert trigger fires on 4 different events :- before(insert, update), after (insert, update)
  • Merge trigger are fired on both events on delete
  • Field history is updated after the trigger has successfully finished processing data.
  • Any callout should be asynchronous so that trigger does not have to wait for the response.
  • A trigger cannot have a static keyword in its code.
  • If a trigger completes successfully the changes are committed to the database and if it fails the transaction is rolled back.
25)Write the syntax of Apex Trigger?
Trigger TName On ObjName(name the events){
……. Apex code here ……
26)What are context variables in regards to trigger?
Following are the context variable available in triggers. Please note variable’s availability varies according to the type of trigger events.
  1. isExecuting
  2. isInsert
  3. isUpdate
  4. isDelete
  5. isBefore
  6. isAfter
  7. isUndelete
  8. new
  9. newMap
  10. old (update and delete only)
  11. oldMap (update and delete only)
  12. size
27) How is Trigger.New Different from Trigger.newMap?

Trigger.New variable returns the list of sObject which has invoked the trigger and Trigger.NewMap returns the map of ID’s with the newly entered records. NewMap is only available in after insert, before and after the update and after undelete.
28)How is Trigger.new different from Trigger.old?
Trigger.New variable returns the list of sObject which has invoked the trigger and Trigger.old returns a list of the older versions of the records which have invoked the trigger. Trigger.Old is only available in update and delete events
29)Can a trigger call a batch class?
Yes, we can call a batch class in the trigger as we do in the normal apex code.
30)Can a trigger make a call to Apex callout method?
we can call a callout method in Apex Trigger but the only condition is that it has to be an asynchronous callout because the trigger flow cannot wait on the response received by the callout method.
31)Define Recursive Trigger and how to avoid it?
There is a possibility that the result of the trigger can end up calling the same trigger again and can run in a loop, this is known as a recursive trigger. To avoid this scenario we should create a static variable and check the value of this variable before we execute anything in the trigger.
32)What do you mean by the bulkifying trigger?
A trigger that can handle both single record and thousands of record. It is capable of handling mass action.
33)Is there any limit on number of triggers define on an object?
We can define as many triggers on an object as we want but it is recommended to have one trigger per object because the order of execution of different trigger is not guaranteed and any trigger can fire first.
34)Can you explain the order of execution in Triggers?
Following is the order of execution of events which Salesforce perform before a DML Event.
  1. The record is loaded from the database or is initialized in case of upset statement.
  2. New record’s field values are overwriting the old values, now depending on the origin of the request this flow varies: if the request is from a UI page then the following validations are performed by Salesforce:
    1. Any layout specific rules are checked
    2. All the required values are checked at layout and field level
    3. All the field formats are validated along with the maximum length of field values
If the request originates other than UI then Salesforce only checks for Validation of foreign keys.
  1. Now all the before triggers are executed at the database.
  2. Most of the validations are performed again to verify that all the required fields are holding some values and are not null, at this step user defined validations are also executed and the only validation which is not repeated in this step are the rules specific to the layout.
  3. After the success of the previous step, the record is reviewed for duplicate records, by running the duplicate rule. If a duplicate is found the flow is stopped and no further actions performed.
  4. In this step, record is saved to the database but it not committed yet.
  5. Now all the after Triggers are executed.
  6. In this step, assignment rules are executed.
  7. Now if there is any auto-response rule is present then they are executed.
  8. Next in the queues are the workflow, they are executed after the auto response.
  9. If the workflow was updating a field, then the fields updated in this step and the flow after this step varies if this was the case.
  10. If a field was updated then the before and after update triggers are fired once more and standard validation are also executed again. Custom validation escalation rule and duplicate rules are not required to run again.
  11. Once the execution has reached this stage, then process is fired if there are any declared on the object.
  12. Now the escalation rules are executed.
  13. Entitlement rules are executed if any.
  14. If there are any roll-up summary field, then they are calculated at this step and the parent object go through the save process.
  15. Now the sharing rules are executed.
  16. If we reach this stage, then that means no error has occurred and the data is ready to be committed to the database and is committed now.
  17. Now if there is any post-commit logic like email, then that is executed
  35) Which of the below can’t be used in Apex DML Operation?

a) trigger.old 
b) trigger.new
c) trigger.new and trigger.old 
d) None of the above
36)When considering trigger context variables, which of the statement is true?

a) We can delete trigger.new
b) We cannot delete trigger. new
c) trigger.new is always ready only
d) trigger.new is ready only, so we can delete
e) None of the statement is true
37)On deletion of parent record, the child record should not getddeleted, which relationship will satisfy this requirement?

a) Lookup
b) Master-Detail
c) Many to Many
d) Master to Master
e) Both b & c
38)Product manager at XYZ company is required to help their sales team in selling certain products, but product manager does not have access to the opportunities and his involvement is required in assisting the deal. How will a salesforce admin resolve this scenario?

a) Notify the product manager using opportunity update reminders 
b) Enable opportunity teams and allow users to add the product manager.
c) Use similar opportunities to show opportunities related to the product manager.
d) Enable account teams and allow users to add the product manager.
39)When would a developer use upsert and external IDs? (There are two correct answers.)

a)To integrate with an external system
b) To migrate customizations from sandbox to production.
c) To load related records without knowing Salesforce record IDs.
d) To use the Web Services API to query for data.
40) Considering child to parent relationship, you can traverse 

a) up to five levels
b) up to one level only
c) up to three levels
d) up to four levels
e) All of the above statements are true
41) Which of the Data format and communication is supported by REST API?

a) XML and Synchronous
b) JSON, XML and Asynchronous
c) JSON, XML and Synchronous
d) JSON and Synchronous
e) None of the above
42) Which of the authorizations are supported by SOAP API ?

a) Session ID 
b) Oath 2.0
c) Both Oath 2.0 and Session ID
d) None of the above

43)Which one is a valid exception handling block in Apex?
a) try { code block }
catch (exceptionType)
{ code_block }
finally code block

b) try { code block }
catch (exceptionType)
code block
c)try { code block }
catch (exceptionType) {
code block }
catch (Exception e){ }
d) All of the above.
e) None of the above.
43(i)  Class annotated with isTest must be declared as?
d)Private and Public both
e) None of the above
44) Which statement is False regarding the isTest annotation

a) Classes defined as isTest must be declared as Private.
b) Classes defined as isTest do not count against organizations limits for Apex scripts.
c) Classes defined as isTest cannot be called from another class or trigger.
d) Classes defined as isTest can only contain methods declared as test methods.
e) None of the above
45) Given the controller code what is the expected output?
<apex:page controller=”the controller”>
<apex: page>
public class theController
public string out{
get {
if(out== null) out = ‘getter’;
return out ;
public theController()
Out= ‘constructor’;
public void setout
{ out = ‘action’; }

a) null
b) action
c) constructor
d) getter.
46) Which among these is a valid SOQL to query all records in an organization, including delete and archived activities?

a) SELECT count() FROM contact WHERE accountid = a.id QUERY ALL.
b) SELECT count() FROM contact WHERE accountid = a.id INCLUDE ALL.
c) SELECT count() FROM contact WHERE accountid = a.id ALL ROWS.
d) None of the above.
47) Customer wants to add a custom validation process to the contact save process. Before the record is created and saved to the database, the customer wants run a validation, which will checks if the associated account is active or not, this validation should be active for all UI as well as integration requests. Which design accomplish this

a) A custom Web service
b) A before insert trigger
c) A custom Visualforce controller
d) A client-side 5-control
48) What types of element do list contains.

a) Integer
b) String
c) Object
d) Integer and string
e) All of the above

49)Define Self Relationship in Salesforce?

A. It is a look up Relation to the same object.

50)Can we call a Future method from batch class?

No, we cannot directly call a future method from a batch class

I hope you have found the above Interview Questions useful.

For more updates, follow us on Social Media





No comments:

Post a Comment