1. What is Apex?
Apex is a strongly typed, object-oriented programming language that allows developers to extend the Salesforce platform by writing their own business logic into the platform. Apex looks similar to Java and can be launched through a variety of user-initiated events such as record updates, button clicks, triggers on objects, or external web service requests.
2. What is a Trigger?
Apex triggers enable you to perform custom actions before or after events to records in Salesforce, such as insertions, updates, or deletions. Just like database systems support triggers, Apex provides trigger support for managing records.
Use triggers to perform tasks that can’t be done by using the point-and-click tools in the Salesforce user interface. For example, if validating a field value or updating a field on a record, use validation rules and workflow rules instead.
3. Write Trigger Syntax
trigger TriggerName on ObjectName (trigger_events) {
code_block
}
4. On which events a trigger can fire?
A trigger is a set of statements which can be executed on the following events. In the above trigger statement one or more of below events can be used with comma separated.
- before insert
- before update
- before delete
- after insert
- after update
- after delete
- after undelete
5. What are different types of Triggers?
There are two types of triggers:
Before triggers are used to perform a task before a record is inserted or updated or deleted. These are used to update or validate record values before they are saved to the database.
After triggers are used if we want to use the information set by the Salesforce system and to make changes in the other records. are used to access field values that are set by the system (such as a record’s Id or LastModifiedDate field), and to affect changes in other records. The records that fire the after trigger are read-only.
6. How does Salesforce deploy Sales Tracking?
Salesforce records data on details such as sales numbers, customer details, repeat customers & customers served and use these to create detailed reports, charts, and dashboards. This way it keeps a track of sales in your organization.
7. What is the difference between isNull and isBlank?
Use the ISBLANK() function for text fields. As text fields can never be NULL, even if nothing is provided as a value, ISNULL() function takes only an empty value. If ISNULL() is used with a text field then it returns false.
8. What is the difference between insert() and database.insert() ?
Using the insert method, we can insert the records but if any error occurs in any record system will throw an error insertion failure and none of the records are inserted. If we want to execute partially success of bulk insert operation we will use database.insert.
9. What is SOQL and SOSL?
SOQL (Salesforce Object Query Language) and SOSL (Salesforce Object Search Language) are two query languages used in Salesforce for querying and searching data.
SOQL (Salesforce Object Query Language):
- SOQL is used to query records from a single object or related objects in Salesforce.
- It is similar to SQL (Structured Query Language) and follows a syntax that allows you to specify which fields to retrieve, filter criteria, order of results, and relationship traversal.
- SOQL queries are executed against Salesforce objects and can retrieve both standard and custom object records.
SOSL (Salesforce Object Search Language):
- SOSL is used to perform text-based search across multiple objects in Salesforce.
- It allows you to search for records that match a specific search term or phrase, regardless of the object they belong to.
- SOSL is especially useful when you want to perform global searches or search across multiple objects with a single query.
- SOSL queries can include wildcards, phrase searches, and search modifiers to refine the search results.
Key differences between SOQL and SOSL:
- SOQL is used for querying records from a single object or related objects, while SOSL is used for searching records across multiple objects.
- SOQL provides more precise control over the data returned, allowing you to retrieve specific fields and apply detailed filtering conditions.
- SOSL is optimized for text-based searches, and it returns a list of lists that represent search results grouped by objects.
- SOQL supports relationship queries to traverse and retrieve data from related objects, while SOSL doesn't support direct relationship queries.
Both SOQL and SOSL are powerful tools in Salesforce for retrieving and searching data. Understanding when to use each query language will help you efficiently retrieve and manipulate data based on your specific requirements.
Unlock your potential as a Salesforce Developer with our Salesforce Developer Training program.
10. What are the three types of object relations in Salesforce?
Different types of object relations in Salesforce includes:
- One to many
- Many to many
- Master-detail
11. Is it possible to schedule a dynamic dashboard in Salesforce?
No, it is not possible to schedule a dynamic dashboard in Salesforce.
12. What is the meaning of Governor Limits in Salesforce?
In Salesforce, Governor Limits helps you to control how much data or how many records you can store in the shared databases. Salesforce uses a single database to store data from different clients.
13. Name types of bindings used in Visualforce
- Three types of bindings used in Salesforce are:
- Data bindings: It refers to the data set in the controller
- Action bindings: It refers to action methods in the controller
- Component bindings: It refers to some other Visualforce components.
14. What is TAB in Salesforce?
In Salesforce, "TAB" typically refers to a "Custom Object Tab." Custom Object Tabs allow users to access and interact with custom objects that they've created or customized in their Salesforce organization. These tabs enable users to view, create, edit, and manage records associated with those custom objects, extending the functionality of Salesforce to suit specific business needs.There are three types of tabs.
- Custom Tabs
- Visual force Tabs
- Web Tabs
15. What is workflow?
Workflow is an automated process that fires an action based on Evaluation criteria and rule criteria.
- We can access a workflow across the object.
- We cannot perform DML operation on workflow
- We cannot query from the database.
16. What is a Visualforce Page?
Visualforce is the new markup language from salesforce, by using which, we can render the standard styles of salesforce. We can still use HTML here in Visualforce. Each visualforce tag always begins with apex namespace. All the design parts can be determined by using Visualforce Markup Language and the business logic can be written in custom controllers associated with the Page.
17. What are the types of email templates available in salesforce?
There are four kinds of Email Templates
- Text
- HTML with Letterhead
- Custom HTML
- Visualforce
18. How many records can a select query return? How many records can a SOSL query return?
- The maximum number of records that SOQL command retrieves is 50,000.
- The maximum number of records that SOSL command retrieves is 2,000.
19. Which fields are automatically Indexed in Salesforce?
The following fields are automatically indexed in salesforce.
- Primary keys - Id, Name and Owner fields.
- Foreign keys - lookup or master-detail relationship fields.
- Audit dates such as SystemModStamp.
- Custom fields marked as an External ID or a unique field.
20. What are the different methods of batch Apex class?
The “Database.Batchable” interface contains three methods for implementation:
- Start method: global (Database.QueryLocator | Iterable) start(Database.BatchableContext bc) {}
- Execute method: global void execute(Database.BatchableContext BC, list){}
- Finish method: global void finish(Database.BatchableContext BC){}
21. What is page layout and Compact layout?
Page Layout is used for web applications and Compact Layout is used for Mobile applications.
22. How many ways can we share a record?
Role hierarchy, OWD (Organization Wide Default), Manual Sharing, Criteria based sharing rules and apex sharing.
23. What is trigger.new and trigger.old?
Trigger.new returns a list of new versions of sObjects records. This Sobjects is only available insert & update and records only modified in before triggers.
24. What is Trigger.NewMap and Trigger.OldMap?
Trigger.NewMap is a map of new ID versions and Trigger.OldMap is a map of old ID versions.
25. What is Enum in Apex?
An enumeration is an abstract data type that stores a value of a finite set of specified identifiers. You can define an enumeration using the keyword Enum. Enumerations can be used as any other data type in Salesforce.
26. Difference between database methods and DML statements?
Differences between database methods and dml statements:
- 1. DML statement: Some updates are not allowed. For example, if there are 20 records in the list, all records will be updated or not updated.
- Database method: Allow partial updates. You can specify the parameter to true or false in the Database method, true to allow partial updates, false to not allow the same.
- 2. DML statement: You cannot get a list of success and failure records.
- Database method: You can get a list of success and failure records, as we saw in the examples.
- 3. DML Statement Example: insert listName;
- Database Method Example: Database.insert(listName, False), where false means partial updates are not allowed.
27. How do you debug the code in Apex?
In Apex, we have some tools for debugging. One of them is the system.debug() method, which prints the value and output of the variable in the debug log.
There are two tools that you can debug:
- Developer console
- Debug log
28. What is Blob in Apex?
Blob: Binary storage type, generally used to receive uploaded attachment documents, etc.
29. What is the ID type in Salesforce Apex?
ID: This type is unique to Salesforce and is used to represent the 18-bit id identifier of salesforce’s sObject.
30. What does the contains method do in Apex?
contains() to see if the string contains a method for a specified string.
E.g:
String str1 = ‘xyz’;
String str2 = ‘y’;
str1.contains(str2); //true
31. Can you please help with some string methods?
- startsWith()- whether the string begins with a given string.
- endsWith()- whether the string ends with a given string.
- toUpperCase()- which is capitalized.
- toLowerCase()- which is changed to lowercase.
- length()- to find the length of the string.
- replace()- replaces the string matching content.
- split()- splits the string into a List collection according to the specified string.
- trim()- remove the spaces before and after the string.
- indexOf()- which gets the index of the first match of the string with the given string, and -1 if there is no match.
- lastIndexOf()- which gets the subscript of the last match of the string with the given string, and no.
- substring()- intercepts the string between the given subscripts in the string.
32. What are sharing rules in Salesforce?
Sharing rules help users to share records based on certain conditions.
33. What are different types of sharing rules?
The two types of Sharing rules are owner-based sharing rules and criteria-based sharing rules.
34. What are web services?
Web service is a standardized medium to propagate communication between the client and server applications on the World Wide Web. Web services provide a common platform that allows multiple applications built on various programming languages to have the ability to communicate with each other.
Webservices is a functionality or code which helps us to do integration. Web services are open standard (XML, SOAP, HTTP, etc.) based web applications that interact with other web applications for the purpose of exchanging data.
35. Name a few LWC targetConfigs.
- lightning__AppPage
- lightning__HomePage
- lightning__RecordPage
- lightning__Tab
- lightning__FlowScreen
36. What are Event.bubbles and Event.composed?
- Event.bubbles: A Boolean value indicating whether the event bubbles up through the DOM or not. Defaults to false.
- Event.composed: A Boolean value indicating whether the event can pass through the shadow boundary. Defaults to false.
Enhance your Salesforce development skills with our specialized Salesforce Developer Training training.