Salesforce Interview questions on DML
Q. How many types of DML statements does Salesforce supports?
A. There are altogether 6 types of statements:-
Insert
Delete
Update
Merge
Undelete
Upsert
Q. How many DML statements are allowed in on transactions?
A. Salesforce allows 150 DML statements per transaction.
Q. 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.
Q. 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;
Q. 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
Q. What is SOQL?
A. It stands for Salesforce Object Query Language.
Q. How many SOQL we can perform per transaction?
A. We can perform 100 SOQL statements per transactions.
Q. How can we fetch top 5 opportunity according to the amount?
A. Select Name, id from opportunity order by desc amount limit 5.
Q. How many records can we fetch using one SOQL query?
A. We can get upto 50000 rows of records per SOQL query.
Q. 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
Q. What is SOSL?
A. It stands for Salesforce Object search language.
Q. How it 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.
Q. How to use filter on Name field if only partial string value is known?
A. SELECT Name, id FROM Account WHERE Name LIKE ‘Z%’
Q. 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-04-26T10:00:00-08:00
For Date : SELECT Name, id FROM contact WHERE CreatedDate > 2017-04-26
Q. How to filter Boolean field in SOQL?
A. The syntax of where clause would be something like this:- ’ Where BolleanFieldName = True ‘
Q. 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’ )
Q. 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.
Q. What are the considerations for using Group by clause?
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.
0 Comments