# Salesforce Interview Questions
## Introduction to Salesforce
Salesforce is a Customer Relationship Management(CRM) platform that uses cloud technology to bring companies and customers together. It helps businesses to manage their customer's data, track their activities efficiently. It supports powerful, connected products for improving your marketing, sales, commerce, service, IT and more. Salesforce CRM does not need any technical knowledge to set up and manage the same.
## Features of Salesforce
- **Contact management:**
- It provides easier contact management by giving an access to critical data of the customers and interaction history.
- It gives a complete customer details including insights and engage-enhancement strategies. Social data of the customers can be used for a deeper understanding of their particular behavior regarding any product or service.
- **Opportunity management:**
- Salesforce provides an opportunity to view the activity timeline of your customers. It represents different stages of a particular deal which helps you to decide your next move.
- You can see critical details of the activity timeline in addition to the business competitors. The readymade templates ensure hassle-free emailing to the clients.
- **Quote management:**
- Quote management of the products will have tracking of the products, which are part of your deal and it includes the standard price, product code, quantity and quoted price. Also, you can establish quantity along with revenue schedule and it reflects the delivery terms and payment.
- Salesforce CRM app is having a built-in quoting mechanism that automatically quotes client data. It also creates approved template PDF and sends it directly to the customer as an email.
- **Lead management:**
- Lead management is featured with an affluent activity timeline. It provides an access to up-to-date contacts on the timeline. Also, it makes use of sales path to understand the related documents.
- CRM app functions as a fast lead converter machine, which informs you about the original source of the leads. The automatic emailing boosts your revenue generating mechanism.
- **Sales data:**
- Using Salesforce CRM you can get the right sales data at the right time. It provides the faster connection with key decision makers.
- You can easily plan territories. It can be used for increasing sales and marketing productivity with the latest and most accurate data.
- **Mobility:**
- The Salesforce mobile app turns your mobile device into a portable sales office by allowing the users to access CRM data at anytime and from anywhere.
- You can log calls, work opportunities, check dashboards, respond to hot leads etc.
- **Workflow and approvals:**
- It allows to use visual workflow to rapidly design and automate any of the business process with drag and drop simplicity. And you can successfully manage flexible approvals processes for deal discounts, expenses and more.
- **File sync and share:**
- It’s easier to share files, discuss them, publish the best and track your content in real time by using Salesforce.
- You can quickly find what you are looking for, share it securely and also subscribe to receive alerts when something changes.
- **Dynamic dashboards and custom reports:**
- Dashboards offer a real-time picture of how your business is performing in the market. Users can recognize market trends, calculate the activities and clear up the quantities. You can build your own dashboard by using drag and drop icons in Salesforce CRM.
- It allows to create your own customized sales forecasting report with Salesforce CRM. By using simple drag and drop feature, users are able to adjust the fields and view data with filters. Charts provides the real-time data to give you the latest insight.
- **Sales forecasting:**
- It tracks the journey of the leads in the pipeline to look into whether they are reaching their destination i.e. deals or not. It gives a brilliant forecasting on sales upon analyzing the same. You can apply your right judgment to the forecasted amount and according to that you can plan your strategies.
- You can make use of in-line editing, multicurrency support, override visibility etc. to stay on top of your business.
- It gives right credit to the right person and permits to see the forecast as per overlays.
## Scope of Salesforce
Salesforce is a preferred career option if you are looking forward to CRM. A lot of companies like Accenture, Adidas, Atlas, Cisco, Deloitte, Godrej, Infosys etc. are making use of Salesforce. Those who opted for Salesforce are enjoying high scale of pay and extreme job satisfaction. As the number of Salesforce platform end-users increases, companies face lack of proficient skill sets about Salesforce. They want Salesforce proficient people who know the platform very well and can use its several services for business needs. Hence, Salesforce professional count is increasing day by day.
## Salesforce Interview Questions
### Salesforce Basic Interview Questions
#### 1. What is Salesforce?
Salesforce is a Customer Relationship Management(CRM) platform that uses cloud technology to bring companies and customers together.

#### 2. What is an object in Salesforce?
In Salesforce, objects are database tables that are used to store data of an organization. There are two types of objects in Salesforce. They are:
1. **Standard object**: These are the objects provided by the Salesforce platform, which includes contacts, accounts, cases, campaigns, opportunities, leads, products, contracts, reports, dashboards etc.
2. **Custom object**: They are objects created by developers based on the business process. It stores the important and unique information of an organization. It gives a structure for data sharing. Custom object includes page layouts, custom fields, relationship to other objects, custom user interface tab etc.
#### 3. What is meant by an App in Salesforce?
- An App in Salesforce is a logical container that holds various details related to company such as a logo, name, business operations etc. You can customize apps to match your needs, or you can develop new applications by combining custom and standard tabs.
- The process to create an app in Salesforce is given below:
Setup ---> build---> Create---> App---> Click on new.
By following above procedure, you can develop an application as you want.
#### 4. Explain different types of apps we can use in Salesforce.
There are two types of apps that we can create in Salesforce. They are:
1. **Custom app:** They are mainly used by business owners who wants to build an app that suits their business requirements from time to time. It's widely used in the market.
2. **Console app**: It can be used only in the client service business, where we focus on tackling the client’s issues. Compared to custom app it's not widely used in the market.
#### 5. What is sharing rule?
- Sharing rules are applied when an user wishes to permit access to other users like public groups, roles or territories. It gives greater access to particular users by making automatic exceptions to your organization-wide sharing settings.
- You can define total sharing rules up to 300 for a particular object, including criteria-based or guest user sharing rules up to 50, if available for the object.
#### 6. What is an Audit trail in Salesforce?
- An Audit trail in Salesforce is an unique feature that helps in tracking the changes that made in the organization by you and other administrators. In that way you will always get to know who has modified the project at the last minute. It is helpful for the organization with more number of administrators.
- By using an audit trail, you can get to know the details about changes made, date and time of the change and username of the team member who made the changes.
#### 7. What is the difference between role and profile?
| Role | Profile |
| -------- | -------- |
|The role helps in defining data visibility for a particular user| A profile sets the limition for what an user can do in the organization|
|Based on hierarchy, a role defines which user data an user can see| Profile defines permissions|
|Defining role to an user is mandatory| Defining profile is not mandatory|
|Roles provides a feature to control access to records by impacting reports. For example,“My Teams” filter. Roles function if an security model (OWDs) of an organization is set to private.| Profiles helps to decide record privileges i.e. assuming the user can observe the record, it concludes what the user can function, edit, delete, view on that record. It controls other system privileges like export data, mass email etc.|
#### 8. What is a profile in Salesforce? Can two users have the same profile?
- The profile in Salesforce is defined as a collection of settings and permissions that define what an user can do in Salesforce. So it gives you the authority to access certain records in Salesforce. There are multiple profiles available in Salesforce. For example, a sales profile can have access to leads, contacts, campaigns, opportunities etc.
- The people who works under one department may be assigned with same profiles. Consider the case of sales profile, many people work under it and each person works under this is assigned with the same profile. Hence we can say that any number of people can have the same profile.
#### 9. What is a Master–Detail relationship in Salesforce?
- Master-Detail relationship is a relationship between a parent and child where master represents the parent and the detail represents a child. This relationship can be used when we want to control the display of detail records based on the value present in the master record.
- The master object completely takes control of the behaviour of Detail object. The survival of the child is dependent on the parent, because if the parent gets deleted then child automatically gets deleted. You can create Roll-up summary fields in master records which will calculate the SUM, AVG and MIN of the child records.
- Consider an example of courier company model, where a delivery schedule is always linked to a delivery location. If we delete a delivery location from our list, then all the related delivery schedules should also be removed. Such a dependency can be achieved only through Master-Detail relationship.
#### 10. What is dashboard in Salesforce?
A dashboard in Salesforce is a pictorial representation of the report. It displays data from source reports as visual components. These components provide a snapshot of key metrics and performance indicators of the organization at a single glance. A single dashboard is capable of displaying 20 reports at a time.
#### 11. What do you understand by workflow in Salesforce?
- Workflow in Salesforce allows you to automate standard internal procedures and processes for saving time across your organization. It helps to evaluate records as they are created or updated and determines if an automated action needs to occur.
- Automation functions in Salesforce includes the functions such as sending follow-up emails, tracking the customer map journey, performing other marketing activity to boost the sales of the company etc.
- A workflow rule is the major container for a set of workflow instructions. These instructions are usually summed up in an if/then statement. Workflow rules are divided into two main components. They are:
1. **Criteria:** The “if” part of the “if/then” statement i.e., what must be true of the record for the workflow rule to execute the related actions.
2. **Actions:** The “then” part of the “if/then” statement i.e., what to do when the record meets the criteria.
- Consider an example for a workflow, "if it is raining, then bring an umbrella". In this example, the criteria is “it is raining” and the action is “bring an umbrella”. If the criteria isn’t met, then the action isn’t executed. Workflow rule's actions are executed only when a record meets all the criteria of a workflow rule.

#### 12. What are the benefits of using Salesforce CRM?
Benefits of using Salesforce CRM is given below:
1. **Communicate using automation tools:** With the help of Salesforce Einstein Bots, it's features can automatically respond to chats on time. Thus avoids giving delayed response.
2. **Data syncing from different applications:** Data from other applications such as MailChimp and G Suite can be integrated into Salesforce platform. This removes the difficulty of moving from one software to another. Using Salesforce mobile app, you can keep track of your data anytime and anywhere.
3. **Utilization of data analytics tools:** Salesforce's Einstein analytics gives insights so that users can address the changing data right away. Salesforce has a collection of reporting tools and dashboards that will help you collect information and work on it properly.
4. **Following customer activity:** It helps to understand the customer's journey through sales cloud so that you will have an easier access to their behaviour and background. You can review the click rates on your email campaigns to help you recognize what works best for your customers.
5. **Assisting customer through chat:** A chat box is provided by service cloud's live agent depending on the interaction of your customers or followers on your web page. By connecting with the customer profile, your service team can deliver answers. This is helpful in improving customer experiences by letting agents respond quickly.
6. **Using an omnichannel feature:** Multi-channel feature provided by service cloud automatically shifts conversations from various channels directly to the agents. This gives them one place to connect with customers through call, social media, chat, messaging or email.
7. **Consistent engagement with current customers:** Looking for a new customer is more expensive than keeping the current ones. Use the gathered data in Salesforce's CRM to create consistent marketing campaigns.
8. **You can build apps:** `Force.com`, a Platform as a Service(PaaS) simplifies customizing and building apps for any device without using a complicated infrastructre.
#### 13. What is trigger in Salesforce?
- The trigger is defined as an Apex code that executes to perform custom actions, before or after modifications like insert, update, delete etc. that has done to records in Salesforce.
- Triggers can be defined for top-level standard objects, like contact or account, custom objects and few standard child objects.
- They are active by default when created. When the specified database events occur, Salesforce automatically fires active triggers.
- Syntax for creating a trigger is given below:
```
trigger TriggerName on ObjectName (trigger_events)
{
code_block
}
```
To execute a trigger before or after insert, update, delete and undelete operations, specify multiple trigger events like `before insert`, `before delete`, `after insert`, `after update` etc. in a comma-separated list.

#### 14. What is the difference between static and dynamic dashboards in Salesforce?
| Static dashboards | Dynamic dashboards |
| -------- | -------- |
| These are the default dashboards which are visible to any user| Dynamic dashboards shows data tailored for a specific user |
| It is used to show organizational-wide data to a set of users | It is used to show single user’s specific data, such as the number of sales closed, leads converted etc|
|It can be scheduled to automatically refresh its data| We can't schedule dynamic dashboard because when the dashboard is opened by us, it will display the real-time generated data|
#### 15. What is Apex in Salesforce?
- Apex is a strongly typed and object-oriented programming language that permits developers to execute flow and transaction control statements on Salesforce platform servers in conjunction with calls to the API. It uses syntax that looks similar to Java and pretends like database stored procedures.
- Apex allows developers to add business logic to many system events, including Visualforce pages, button clicks and related record updates. This code can be initiated by requests from web service and from triggers on objects.
- All Apex code runs completely on-demand on the Lightning platform. Apex code is written and saved to the platform by developers. Through user interface, end users trigger the execution of Apex code.
### Salesforce Intermediate Interview Questions
#### 1. What are Governor limits in Salesforce?
- Governor limits control how much data a shared database can store. They help to make sure that no one monopolizes the shared resources like storage, CPU and memory. Whenever the Apex code exceeds the limit, it issues a runtime exception which cannot be handled.
- The following list gives some of the governor limits in Salesforce:
- Push notification limits
- Per-Transaction Apex limits
- Size-Specific Apex limits
- Miscellaneous Apex limits
- Static Apex limits
- Email limits
- Examples of governor limits in Salesforce:
1. Total number of sendEmail methods permitted is 10.
2. Total number of records retrieved by a SOQL query is 50,000.
3. Maximum CPU time on the Salesforce servers is 10,000ms on synchronous Apex.
4. Total number of callouts(web services calls or HTTP requests) in a transaction is 100.
#### 2. What is junction object in Salesforce?
- Junction objects are useful in building many-to-many relationships between objects in Salesforce.
- Consider an example of recruiting application, where a position for a job is linked to many candidates or a candidate can apply for many other jobs. Here, a third party object "job application" is referred to as a junction object in order to connect the data model. In the above given example, “job application” is the junction object.

#### 3. What are Permission sets?
A Permission set is a collection of settings or permissions that is used to give access to numerous tools and functions for the user. You can use permission sets for different types of users to extend the functional access without changing their profiles. Instead of creating a separate profile each time, you could easily create a Permission set.
#### 4. What are the different types of reports available in Salesforce?
- Reports will give clear picture to the management. Management will make use of reports to track progress towards its various goals, increase revenue and control expenditure. Reports will also help to predict trends and thus gives the advantage of increase in profits.
- There are four types of reports in Salesforce. They are as follows:
1. **Matrix report:**
- A report that is formed by grouping the records by rows as well as columns. It is used when you want to see data by two seperate dimensions that aren’t related, such as date and product.
- Example: Summarize opportunities by account horizontally and by month vertically.
2. **Summary report:**
- A report that provide a listing of data with groupings and subtotals. It is used when subtotals are needed, based on the value of a particular field or when you want to create a hierarchically grouped report.
- Example: All opportunities for your team subtotaled by owner and sales stage.
3. **Tabular report:**
- A report that provides details of company in tabular format. It is used when you want a simple list or an items list with a grand total.
- Example: These reports are used to list all accounts, list of opportunities, list of contacts etc.
4. **Joined report:**
- A report that is created by the mixture of any combination of report. Like matrix report plus summary report can give you a joined report. Also, matrix report and tabular report can give a joined report.
- Example: You can develop a report to display opportunity, case and activity data for your accounts.

#### 5. Explain the `Force.com` platform.
`Force.com` is the entire framework and codebase on which whole Salesforce application exists. We can also say that, Salesforce is built on `Force.com`, which is a Platform as a Service (PaaS) that allows us to simplify the design, development and deployment of cloud-based applications and websites. Developers can work with Cloud Integrated Development Environment(Cloud IDE) and deploy the applications on servers of `Force.com`.
#### 6. Explain different components of dashboard available in Salesforce.
Some of Salesforce dashboard components are explained below:
1. **Gauge:** It is used for displaying a single value within a custom value range.
2. **Metric:** This is used for showing a single pair of key–value. We can enter the metric label directly on the components by clicking the empty text field next to the grand total . All metrics placed in the dashboard column would be displayed as a single component.
3. **Table:** Tables are used for showing report data in the form of lists. For example, top five or bottom five opportunities.
4. **Visualforce page:** It is used for forming a custom component as a dashboard or displaying information which is not available in other component types.
5. **Charts:** It is used for showing comparisons. Charts are divided into 6 types. They are: line Chart, vertical bar chart, horizontal bar chart, donut, pie and funnel.
#### 7. What are validation rules in Salesforce?
- Validation rules in Salesforce consists a formula or expressions that evaluates the data in one or more fields in a record to meet the standards you specify before the user can save the record. It returns “True” or “False” value based on evaluation of the data. Validation rules are responsible for displaying error message to the user when the condition is “True” due to an invalid value.
- Validation rules are helpful in enforcing integrity constraints against the data. Here we give conditions in the formula editor. If one validation rule fails, Salesforce proceeds to check another validation rule held within the field or record and shows an appropriate error message at that particular field or above the record.
- You are allowed to create validation rules for fields, objects, campaign members or case milestones. For example, we can create a validation rule that fires when an user tries to save an account with incorrect length for account number.
#### 8. What causes data loss in Salesforce?
There are many things which causes data loss in Salesforce. They are:
1. **Human error:**
- When editing an object definition (incorrectly changing a picklist), importing data (overwriting good data with bad) or merging households are the common situations where human error may occur.
- For example, when you import data, it becomes important to match up fields. Situations like moving to percent, number and money from other data types or changing text area to URL, email, phone or text etc. will lead to incorrect match in fields. If you are updating large number of records and match up incorrect fields, your records will be invalid.
2. **Accidental deletion of Salesforce data:**
- A record (or multiple records) might be accidentally deleted by users or employees. Deleting records could be because of miscommunication, forgetting to remove a contact from being deleted and many other reasons. So proper training and having a trusted backup/recovery solution is much important.
3. **Purposeful deletion of Salesforce data:**
- Disgruntled employees like the person who has recently got a very bad performance review and thinks their job is at stake or who is jealous of other employees might try to delete the data. A few clicks on delete button may lead into deletion of multiple records from Salesforce.
- If they empty their recycle bin, that data recovery will be difficult using the Weekly Export. It can cause numerous damages if these records are not backed up properly.
4. **Data sync errors:**
- If you have more than one admin, or use Outlook for Salesforce, you might experience a data sync error at some point.
- For example, one admin is trying to refresh a sandbox while another admin is working from home and trying to edit an object type in that same sandbox. When this happens, the admin who was editing the object can lose his work in progress.
- Contacts in Outlook can over-write good Salesforce data when using Outlook for Salesforce, introducing errors through an inappropriate sync.
#### 9. What is Visualforce in `Force.com`?
- Visualforce can be defined as the UI for the `Force.com` platform that allows developers to build sophisticated, custom user interfaces which can be hosted natively on the Lightning platform.
- This Visualforce framework includes a tag-based markup language, a set of server-side “standard controllers” that forms basic database operations(such as queries and saves) and each Visualforce tag corresponds to an user interface components such as a field, section of a page or a related list etc.
- It works on the standard MVC model. It can have strong integration with database and deploy auto-generated controllers for database objects. The behavior of Visualforce components can be controlled by the developer, by utilizing the same logic that was used in standard Salesforce pages. It is also possible for a developer to associate their own logic with a controller class written in Apex code.
#### 10. What are the differences between trigger and workflow in Salesforce?
| Workflow | Trigger |
| -------- | -------- |
| Workflow is an automated process that fires an action depending on evaluation criteria and rule criteria | A trigger is a piece of program code that will be executed before or after a record has been inserted or updated |
| We cannot carry out DML operations on workflow| We can use 20 DML operations in a single trigger|
| We are able to obtain a workflow across the object| We are able to access the trigger across the object and associated with that objects|
| We cannot query from database in workflow| We can use 20 SOQL(Salesforce Object Query Language) from the database in a single trigger |
#### 11. What are record types in Salesforce?
- Salesforce record types permits us to associate different business processes and display different picklist values and page layouts to different users based on the user profile.
- Administrators are having the ability to associate record types with the user profiles so that, in the record’s detail page, different users will be able to see different picklist values and page layouts.
- For example, consider a case where record types are most oftenly used i.e., to create two different sales processes on the Opportunity object. Each of them with different sales stages and page layouts. This will indicate that with record types you will be able to apply multiple page layouts per object as well as per user profile.
- *Benefits of record types:*
- It modifies user interaction experience to specific needs of business.
- Allows for administration in a simple manner as there are fewer fields to maintain.
#### 12. What are page layouts related to Salesforce?
- Page layouts are used to control the layout and organization of buttons, fields, Visualforce, custom links, s-controls and related lists on object record pages.
- They are helpful in organizing user interface pages by determining which fields, related lists and custom links are required, read only and visible for the user.
- We can create many page layouts and apply it to different user group, with the aim of creating a customized experience. For example, you could have single account record like ACME Corp., but it displays different information depending on your user profile.
- Here, you can only apply one page layout to single group of users per object, per record type. For example, if you have one record type based on the Accounts object, you can apply only one page layout per profile.
#### 13. What are the two types of triggers in Salesforce?
Below are the two types of Apex triggers in Salesforce:
1. **Before triggers:** It can be used to update or validate record values before it is saved to the database.
```
trigger TriggerName on ObjectName(before event) //Here event can be insert, update or delete
{
code_block
}
```
2. **After triggers:** It can be used to access field values of the records that are set by the system (such as record's ID or LastModifiedDate field) that are stored in the database and use this field value to do the changes in other records. Records that fires the after trigger are read-only.
```
trigger TriggerName on ObjectName(after event) //Here event can be insert, update or delete
{
code_block
}
```
#### 14. What is fiscal year or economical year in Salesforce?
- The fiscal year or economical year is defined as the period of time used for calculating annual financial statements based on starting and ending date of a company's financial year. In this period of time, whatever the amount of business that Salesforce has done can be considered as fiscal year and depicts the Salesforce revenue.
- There are two types of fiscal years in Salesforce. They are:
1. **Normal or standard fiscal year:** It is a period that allows estimating by following the Gregorian calendar year that has 12 month structure. Starting of the fiscal year can begin with the very first day of an any month you choose belonging to a particular year. For example, for the fiscal year starting in April, standard fiscal year is used.
2. **Custom fiscal year:** It is mainly defined for the companies that lay their forecast based on weekly or quarterly financial planning and can also customize the same. For example, you may have 4 quarters with 13 weeks per quarter in a 4-4-5 pattern or 13 periods per year.
#### 15. Explain skinny table. What are the considerations for skinny table?
- Skinny tables in Salesforce are useful in accessing the fields which are frequently used and to avoid joins. This can improve the performance of certain read-only operations such as reports, list views etc. Skinny tables are highly effective, because skinny tables will be in sync with source tables even when the source tables are modified.
- You need to contact Salesforce customer support, if you want to use skinny tables. You cannot create, access or modify skinny tables yourself. For example, you need to contact Salesforce to update your skinny table definition if you want to add new fields.
- *Considerations for skinny tables are*:
- It can contain utmost of 100 columns.
- It cannot hold fields from other objects.
- For full sandboxes, these skinny tables are copied to your full sandbox organizations.
For other types of sandboxes, skinny tables are not copied into your sandbox organizations. To have production skinny tables to be activated, contact Salesforce customer support.
- Below figure displays an Account view, a corresponding database table along with a skinny table that can speed up account queries.

### Salesforce Advanced Interview Questions
#### 1. What do you mean by a sandbox in Salesforce?
- A sandbox is a copy of the production environment/ organization and it is used for the purpose of testing and development. It’s very useful because sandboxes are completely isolated from your Salesforce production organization, so it allows you to test out new ideas on the duplicate database without disturbing the original production environment.
- You can use the sandbox whenever you want to test a newly formed `Force.com` application or Visualforce page. Instead of testing it directly in production, you can develop and test it in the sandbox organization.
- Using this, you can develop the application without any difficulty and then migrate the metadata and data to the production environment. Doing this in a non-production environment permits developers to freely test and experiment the newly created applications.
- There are four types of sandboxes in Salesforce:
1. *Developer sandbox* -
- It is a copy of the production organization, it copies all the informations of an application and configuration to the sandbox. It is mainly used for the development and testing task in an isolated environment.
- This type of sandboxes have limitations upto 200MB of test or sample data. You can refresh a developer sandbox once in a day.
2. *Developer pro sandbox* -
- It copies all of your organization’s reports, dashboards, apps, price books, products and customizations under setup. But it excludes all of your organization’s custom and standard object records, attachments and documents.
- This type of sandboxes have limitations upto 1GB of test or sample data. We can refresh developer pro sandboxes once in a day.
3. *Partial data sandbox* -
- A partial data sandbox is a developer sandbox plus the data you define in a sandbox template, which is intended to be used only as a testing environment. It includes the reports, dashboards, price books, applications, products and customizations under setup (including all of your metadata).
- Additionally, these sandboxes can have your organization’s custom and standard object records, documents and attachments up to 5 GB of data along with a maximum of 10,000 records per choosed object.
- A partial data sandbox are smaller compared to full sandbox and has a shorter refresh interval. You can refresh a partial data sandboxes in every 5 days.
- Sandbox templates permits you to select specific data and objects to copy to your sandbox, thus you can control the size as well as content of each sandbox. Sandbox templates are available only for partial data or full sandboxes.
4. *Full sandbox* -
- It is a replica of production including custom and standard objects records, attachments and documents and is used only as a testing environment.
- You can refresh full copy sandboxes for every 29 days.

#### 2. Explain the various types of object relationships in Salesforce.
An object relationship in Salesforce can be defined as two-way link or association between two or more objects. Relationships are created by generating custom relationship fields on an object. Due to this, whenever an user view the records, they are also able to see and access related data. The various types of object relationships in Salesforce are:
- **Master-Detail relationship (1:n):**
- It is a parent-child relationship where master object controls the behavior of dependent detail and subdetail object. It is a 1:n relationship, in which there is only one parent, but multiple children.
- The master field cannot be empty, since it is the controlling object. If a master object's record or field gets deleted, the corresponding record or fields in the dependent object will also be deleted. This is called a cascade delete. Child object fields will inherit the owner, sharing and security settings from the parent object. You can create Master-Detail relationships between two custom objects, or between a standard object and custom object until the standard object remains as a master in the relationship.
- For example, you can define a Master-Detail relationship with two objects such as Account—Expense report. It expands the relationship to subdetail records, such as Account—Expense report—Expense line item. You will be then allowed to perform operations across the master—detail—subdetail relationship.
- **Lookup relationship (1:n):**
- These relationships are useful for creating a link between two objects, without the dependency on the parent object. This is again a form of parent-child relationship where there is only single parent, but multiple children exists(1:n relationship).
- Despite of master being the controlling field, deleting a master record will not automatically delete the lookup field in child object. So the records in the child object will not get affected and there will not be any cascade delete here. Child fields will not inherit the owner, sharing or security settings of its parent.
- With a lookup relationship, you are permitted to link two different objects or link an object with itself (except for the user object). For example, you may want to link a custom object "Bug" with itself for showing how two different bugs are related to the same problem.
- **Junction relationship (Many-To-Many):**
- You can use this kind of a relationship whenever you want to create two Master-Detail relationships. By linking 3 custom objects, we can create two Master-Detail relationships. In this, two objects will be represented as master objects and the third object will acts as a dependent on both of them. In simpler words, we can say that there will be a child object for both master objects.
- This relationship allows every record of one object to be linked with several records of another object and vice versa. For example, you can create a custom object "Bug" that relates to standard object in such a way that a bug can be related to multiple cases and also a single case can be related to multiple bugs.
- **Hierarchical relationship:**
- This is a special lookup relationship, that is available only for the user object.
- It allows users to use a lookup field to associate a single user with another user that does not refers to itself in a direct or indirect way. For example, to store direct manager of each user, you are allowed to create a custom hierarchical relationship field.
- **External lookup relationship:**
- This relationship links a child standard, custom or external object to a master external object.
- In this relationship, the standard External ID field values on the parent external object is matched against the external lookup relationship field values of the child object.
- **Indirect lookup relationship:**
- This relationship links a child external object to a master standard or custom object.
- For matching and associating the records, you will mention the parent object field and the child object field when you create an indirect lookup relationship field on an external object. Here, you have to select parent object's custom unique, external ID field to match against child object's indirect lookup relationship field.

#### 3. How many ways we can share a record?
With the help of the given below methods we can share records in Salesforce:
- **Role hierarchy:**
- Whenever a user is added to a role, the user above current user in the hierarchy of role will have access for reading the records and inheriting the permissions.
- Follow the steps for role hierarchy:
Go to Setup → find manage users → roles → setup roles → click on ‘add role’ → provide name and click on save.
- **OWD:**
- OWD(Organization Wide Defaults) allows you to give permissions to the organization wide and to define baseline setting for the organization. It is also helpful in defining the user's accessibility level to the user where a user can see other user’s record.
- OWD settings can be Public Read Only, Private, Public Read and Write.
- Follow the steps for OWD:
Go to Setup → find the Security Controls → click on 'sharing settings' → click on ‘Edit’.
- **Manual sharing:**
- Manual sharing is sharing a single record/file to a single user or group of users through manual access.
- We can see a button for manual sharing on detail page of the record and it can be seen only when the OWD setting is private.
- **Criteria based sharing rules:**
- If we want to share records based on condition such as share records with a group of users with the criteria of country is India.
- Follow the steps for criteria based sharing rules:
Go to Setup → security controls → sharing settings → select the object and provide name and conditions then click on save.
- **Apex sharing:**
- Sharing object is available for each and every object in Salesforce. For example, Account object's share object is AccountShare.
- By using Apex, if we want to share the records then we have to create a record to the share object.
#### 4. What is a wrapper class in Salesforce?
- A wrapper class is a type of container class, which contains a group of objects as its members. It is of an abstract data type.
- We use a wrapper class for enclosing the collected data. A wrapper class is defined by programmer, that acts as custom objects, along with wrapper class properties.
- The instances of a wrapper class are helpful in displaying various objects in the corresponding table on a Visualforce page.
- Some of the main advantages of using wrapper class by developers in Salesforce are given below:
- The wrapper class structure is as efficient as that of a good data visualisation process for a web page, especially in the case where the developers are dealing with the JSON structure.
- The developers are not required to manage the passing of any map structure in order to browse necessary elements. Moreover, usage of wrapper class by developers will lead to ease the process of managing relationship between different objects.
- Wrapper class usage prevents any penalty faced by the users for passing an object of Salesforce. Also, it makes the respective object extendable to constructors of class.
- The use of wrapper class supports the developers for efficiently organising the concerned data, provided the data is properly nested.
#### 5. What is Future annotation(`@future`)?
- Future annotations are used to specify methods that are executed asynchronously.
- Methods having future annotation must be static methods and can only return a void type. The arguments specified must be primitive data types or arrays of primitive data types or collections of primitive data types. These methods cannot take sObjects or objects as parameters.
- When you specify a method with `@future` annotation, it will be executed only when Salesforce has available resources.
- For example, you can use future annotation while making an asynchronous web service callout to an external service. Whereas without usage of future annotation, web service callout will be created from the same thread which is executing the Apex code, and no additional processing will take place until that callout is complete (synchronous processing).
- Syntax:
```
global class class_name
{
@future
Static void methodname(parameters)
{
//body of the method
}
}
```
#### 6. What are the differences between SOQL and SOSL in salesforce?
| SOQL(Salesforce Object Query Language) | SOSL(Salesforce Object Search Language) |
|------|------|
| Using SOQL we can search only one object at a time | Using SOSL we can search multiple objects at a time|
| We can query on all fields of any of the datatype| We can query on the fields whose data type is phone, text and email|
| DML operations can be performed on query results| DML operations cannot be performed on search results|
| Indexing happens synchronously| Indexing happens asynchronously|
| We can use SOQL in the classes and triggers| SOSL cannot be used in triggers but can be used in classes|
#### 7. Explain the types of SOQL statements in Salesforce.
Salesforce Object Query Language(SOQL) is useful in querying the records from the `database.com` depending on the requirement. There are 2 types of SOQL statements: Static SOQL and Dynamic SOQL.
1. **Static SOQL:**
- The Static SOQL statement is written using [] (array brackets). This statement is similar to IINQ (Ion Integrated Query).
- It is used in the condition where you don’t have any dynamic changes in the SOQL query. We don't use Static SOQL when the field name or where condition is needed to be dynamically defined.
- Example for Static SOQL query:
```
Contact[] contacts = [SELECT testfield__C, FirstName, LastName FROM Contact WHERE LastName = 'Dhanya'];
```
2. **Dynamic SOQL:**
- It is used to refer the SOQL string creation at run time with Apex code.
- Dynamic SOQL allows you to create more flexible application. For example, you are able to create a search based on end user input or update records with different field names.
- To create a Dynamic SOQL query at run time use Database.query() method, in any one of the given below ways:
1. Return a single sObject when the single record is returned by a query.
`sObjects s = Database.query(string_limit_1);`
2. Return a list of sObjects when more than a single record is returned by a query.
`List<sObject> sobjList = Database.query(string);`
- Example for Dynamic SOQL query:
```
String myTestString = 'TestName';
List<sObject> sobjList = Database.query('SELECT Id FROM MyCustomObject__c WHERE Name = :myTestString');
```
#### 8. What are the different types of email templates available in Salesforce?
The list of different types of email templates that can be created in Salesforce is given below:
- **Text:** All the users in the organization are allowed to create or change these templates.
- **HTML with letterhead:** Only administrators and users with the “Edit HTML Templates” permissions are able to create this templates based on a letterhead. The look and feel of your HTML email templates are defined by the letterheads. It can inherit the logo, text and color settings from a letterhead.
- **Custom HTML:** It is an extension of HTML with a letterhead. Administrators and users having "Edit HTML Templates" permissions can create custom HTML templates without using the letterhead. You must have the knowledge about HTML or get the HTML code to insert it into your email template.
- **Visualforce:** Administrators and developers are allowed to create these templates by using Visualforce. Visualforce templates provides advanced functionalities like merging with a recipient's data, where the content of a template can have data from multiple records.
#### 9. What is Salesforce lightning?
- Salesforce lightning is a component based framework for an application development, which has collection of tools and technologies that aim to effective increasement in the performance of the Salesforce platform. These tools include a entirely new version of a framework, visual upgrades, new and optimized interfaces and more.
- It is designed to simplify processes for business users, who does not have any programming experience.
- Using lightning platform we can easily create apps that solve business problems and provide engaging experiences.
- Few lightning features are:
- *Lightning app builder:* It provides drag and drop capacities to facilitate creation of an application and customization.
- *Lightning component framework:* It consists of tools and extensions that allows the development of reusable components and standalone applications along with customization of the Salesforce mobile app.
- *AppExchange for components:* It makes over 50 partner components present in the app builder.
- *Design system:* It provides style guides and user experience practices for an application development.
- *Lightning Connect:* It is an integration tool which makes it easier for applications of `Force.com` to consume data from an external source that meets the OData specification.
#### 10. Can you give an example of a Salesforce API and its usage?
Salesforce provides variety of API's that allows the developers to interact with the system in many ways. They are:
- **REST:**
- By using REST API you can easily integrate with Salesforce applications using simple HTTP methods in either XML or JSON formats. It is an ideal API for developing mobile applications or external clients.
- Consider an example of retrieving information about the Salesforce version. You need to submit a request for the Versions resource by using following code:
`curl https://yourInstance.salesforce.com/services/data/
`
You have to replace "yourInstance" text with the instance for your organization.
The output from this request is as follows.
```
[
{
"label" : "Winter '12",
"url" : "/services/data/v23.0",
"version" : "23.0"
}
...
]
```
- **Bulk:** The Bulk API provides programmatic access that lets you for quickly loading and querying huge amount of data into your Salesforce organization.
- **Streaming:** The Streaming API can be used to trigger and receive notifications, whenever changes into Salesforce data are made according to the defined SOQL query criteria. It is useful when you want notifications to be pushed from the server to the client based on your defined criteria.
### Conclusion
Salesforce is playing a vital role in any company's sales and marketing automation activities. The demand for qualified Salesforce professionals has seen its peak in the recent days. Moreover, competition is also becoming tough for the Salesforce related positions, so preparation is inevitable if you want yourself to shine out of the crowd.
Salesforce is increasingly used as a term in synonymous with CRM. The organizations can utilize Salesforce for varied applications like Contact Management, Workflow Creation, Customer Engagement, Opportunity Tracking, Task Management and many more. In addition, you can also collaborate with your colleagues, run analytics and access Salesforce from a mobile dashboard.
### References
* "Salesforce for Beginners" by Sharif Shaalan.
* "Salesforce Platform Developer I Certification Guide" by CertSquad Academy.
* "Salesforce Developer Book" by Jay Brewer.
* "Salesforce Platform App Builder Certification" by Rakesh Gupta.
* https://www.tutorialspoint.com/salesforce/index.htm
* https://www.salesforcetutorial.com/
* https://www.youtube.com/watch?v=BA-407HF_fM&list=PLWPirh4EWFpH2LYVIrfmA1RTredCySwP_
* https://www.youtube.com/watch?v=bOzlOkPU0cI&list=PLdYQMTciVWO9xjvh1J7SXjhzpnzWvLih4
### Salesforce Multiple Choice Questions
#### 1. Who can manually share records in Salesforce?
- [ ] a. Record owners
- [ ] b. Administrators
- [ ] c. Users above the record owner in the hierarchy of role
- [x] d. All of the above
- Answer: d. All of the above
#### 2. What does Master-Detail relationships will involve?
- [x] a. Cascading deletes and sharing rules which are controlled by the parent
- [ ] b. Relationship between parent and child elements
- [ ] c. Relationship between master and retail sectors
- [ ] d. Relationship between master and slave drives
- Answer: a. Cascading deletes and sharing rules which are controlled by the parent
#### 3. When should you make use of bulk API?
- [ ] a. When you are using REST requests and prefer to use SOAP
- [ ] b. When you are processing data up to one thousand records
- [x] c. When you are loading large number of records
- [ ] d. When you are updating small numbers of records at a time
- Answer: c. When you are loading large number of records
#### 4. How can you create many to many relationships under salesforce?
- [ ] a. Using a piece of code to relate both objects
- [x] b. Using a junction object
- [ ] c. Not possible to create many to many relationships in salesforce
- [ ] d. Creating a direct many to many relationships
- Answer: b. Using a junction object
#### 5. What do API calls in Salesforce represent?
- [x] a. Specific operations invoked by your client applications at runtime to perform tasks
- [ ] b. Operations invoked at compile time
- [ ] c. Operations that run in the background
- [ ] d. Operations running in the foreground
- Answer: a. Specific operations invoked by your client applications at runtime to perform tasks
#### 6. What must be done before a user can access the API?
- [ ] a. Users must have superuser privelages
- [ ] b. Users must restart the computer
- [ ] c. Users cannot access the API
- [x] d. They must be granted “API Enabled” permissions
- Answer: d. They must be granted “API Enabled” permissions
#### 7. According to roles in the sharing hierarchy, ______ can view and edit the record.
- [ ] a. Nobody can edit the record
- [ ] b. Only the system can edit the record
- [x] c. Only record owner and users beyond the specified role
- [ ] d. There is no record to be edited
- Answer: c. Only record owner and users beyond the specified role
#### 8. Salesforce API calls are
- [ ] a. Some of the calls are asynchronous, rollback on error
- [ ] b. Service requests and responses, asynchronous, committed automatically versus rollback on error
- [ ] c. Service requests and responses, asynchronous, rollback on error
- [x] d. Service requests and responses, synchronous, committed automatically v/s rollback on error
- Answer: d. Service requests and responses, synchronous, committed automatically v/s rollback on error
#### 9. In which file, exception codes are defined in Salesforce?
- [ ] a. In the configuration file
- [x] b. In the WSDL file
- [ ] c. In the error file
- [ ] d. In the spooler
- Answer: b. In the WSDL file
#### 10. Through sharing rules, which type of record access can be granted by administrator?
- [ ] a. Read/Write/Transfer
- [x] b. Read/Write and Read only
- [ ] c. Write only
- [ ] d. Delete
- Answer: b. Read/Write and Read only
#### 11. What can a chatter free user access?
- [ ] a. Accounts
- [x] b. Groups and files
- [ ] c. Custom objects
- [ ] d. None of the above
- Answer: b. Groups and files
#### 12. ______ is not a component of the user record?
- [ ] a. Profile and role
- [ ] b. Language and time zone
- [ ] c. Contact information
- [x] d. Chatter group information
- Answer: d. Chatter group information
#### 13. When creating a sharing rule, what must an administrator select?
- [ ] a. Which records to share
- [ ] b. Who to share access with
- [ ] c. What level of access to grant
- [x] d. All of the above
- Answer: d. All of the above
#### 14. ______ method is not used to share records.
- [x] a. Profile settings
- [ ] b. Sharing rules
- [ ] c. Manual sharing
- [ ] d. Role hierarchy
- Answer: a. Profile settings
#### 15. What groups or individuals comprise public groups?
- [ ] a. Roles
- [ ] b. Roles and subordinates
- [ ] c. Users
- [x] d. All of the above
- Answer: d. All of the above
#### 16. What restrictions does double values in Salesforce have?
- [ ] a. Age and scale
- [ ] b. Scale and position
- [ ] c. Size and time
- [x] d. Scale and precision
- Answer: d. Scale and precision
#### 17. ______ is not a standard object?
- [ ] a. Leads
- [x] b. Invoices
- [ ] c. Accounts
- [ ] d. Opportunities
- Answer: b. Invoices