The document discusses interview questions about Salesforce development including differences between Trigger.new and Trigger.old, whether an ID changes if a deleted record is undeleted, the use of trigger.isexecuting, limitations on passing objects to future methods and calling future methods from other contexts, how the Database.Stateful interface maintains state across transactions in batch Apex, the types of SOQL statements, having clauses in SOQL, differences between using sharing and without sharing in Apex classes, and components that make up Salesforce dashboards.
The document discusses interview questions about Salesforce development including differences between Trigger.new and Trigger.old, whether an ID changes if a deleted record is undeleted, the use of trigger.isexecuting, limitations on passing objects to future methods and calling future methods from other contexts, how the Database.Stateful interface maintains state across transactions in batch Apex, the types of SOQL statements, having clauses in SOQL, differences between using sharing and without sharing in Apex classes, and components that make up Salesforce dashboards.
Developer Interview Questions 1.What is the difference between Trigger.new and Trigger.old and Trigger.newmap and Trigger.oldmap ?
Trigger.new returns new records and Trigger.old
return data before updates were done.
Trigger.newmap returns new records with id's and
Trigger.oldmap return data before updates were done with id's.
2. Is the id of record changes if we undelete a
deleted record?
No, It has the same id.
3. What is the use of trigger.isexecuting?
Suppose we have a method in apex class and we
want this method to run only when the method is getting called from apex trigger than we can make use of trigger.isexecuting in apex class to check if the method is getting called from trigger . 4. Why we cannot pass objects as arguments in future method? Is it possible to call future method from Batch class or another future method? Object data might change between the time you call the future method and the time it actually executes. and hence we pass record id.
No, we cannot call future method from Batch
class or another future method. 21) If downtime occurs and future method was running what will happen?
The Future method execution will be rolled back
and will restart after downtime overs.
5. If the future method was queued before a
service maintenance what will happen?
It will remains in queue and when maintenance is
over and resources are available it will get execute. 6. What is database.stateful interface?
Batch Apex is stateless. Each execution of a
batch Apex job is considered a discrete transaction. If we implements Database.Stateful we can maintained state across transactions. Using Database.Stateful only instance variable holds values static members does not hold values. If we want to count records as batch proceeds maintaining state is important as after one transaction new transaction will start and members will loose their values.
For more information visit: Database.Stateful
in Batch Apex in Salesforce 7. Explain the types of SOQL statements in Salesforce. The Salesforce Object Query Language or SOQL is employed in querying the records from database.com as and when required. The two types of SOQL statements are as follows:
Static SOQL: It is written using [] (array
brackets) and is similar to IINQ (Ion Integrated Query). It is suitable when there are no dynamic changes in the SOQL query. Dynamic SOQL: It is suitable for referring to the SOQL string creation at run time with Apex code. It allows the creation of more flexible applications. For instance, you can create a search based on updated records or end-user input with varying field names. 8. What is having clause? Give the example.
Ans- HAVING is a clause that can be used
in a SOQL query to filter results that aggregate functions return. You can use HAVING clause with GROUP By clause to filter the results returned by aggregate function,such as SUM(). HAVING clause similar to WHERE clause. The difference is that you can include in aggregate functions in a HAVING Clause , but not in WHERE Clause.
Ex- Firstly query,
[Select Id, name from Lead] → It will return
Lead record with Id and Name.
[Select Id, Name from Lead GROUP BY
name] then it will through error like Field be grouped or aggregated: Id [Select id, count(name) from Lead GROUP BY name ]-- then it will also through error , you cannot use same field name used in count i.e-- select id, count(name) from Lead GROUP BY name ^ ERROR at Row:1:Column:18 Grouped field should not be aggregated: Name
[SELECT LeadSource, count(Name) FROM
Lead GROUP BY LeadSource]-- Now it will return record With LeadSource and count total name field correspond to particular LeadSource.
[SELECT LeadSource, count(Name) FROM
Lead GROUP BY LeadSource HAVING count(Name)>6]-- It will filter above group by query and return records which count is greate than 6. 9. Difference between with sharing and without sharing?
Ans- "with sharing" keyword in apex class so that it
will enforce only sharing rules of current user but not, object permissions, field level permissions
But “without sharing” will not enforce only sharing
rules of current user . does it mean it will enforce current user object and field level permissions.
10. What are the various components of the
Salesforce dashboard? Some important components of the Salesforce dashboard are: Gauge: Displays a single value from a custom value range. Visualforce page: Helps in forming a custom component as a display of information unavailable in other component types. Metric: Shows a single pair of key–values. Table: Displays report data in list form. Charts: Provide comparisons and are divided into six types: line chart, horizontal bar chart, vertical bar chart, donut, funnel, and pie.
Ultimate Salesforce LWC Developers’ Handbook: Build Dynamic Experiences, Custom User Interfaces, and Interact with Salesforce data using Lightning Web Components (LWC) for Salesforce Cloud (English Edition)