Salesforce Interview Questions with Answers Part 56

1. Assets best practices in Salesforce

Assets allow you to track specific information about the products and services purchased or installed by customer accounts or contacts Use assets to track everything you need to know about a customers existing products.

While products represent the items that your company sells, assets represent the specific products your customers have purchased. Use assets to store information about your customers' products.

Best practice in using Assets in Salesforce

1. Assets should be created when Opportunity is closed won. Products used in the opportunity should be used for creating it. Account from Opportunity and Product related to Opportunity should be populated on the Asset. Opportunity Line Item can be used for Product code, Quantity, and Price.
2. Asset should be linked to the Opportunity's Account.
3. Use the Competitor Asset check box to track Competitor assets.
4. Work Order creation and Parts Requests can start from Asset in Salesforce for tracking.
5. Asset Replacements
When a customer’s asset needs to be replaced or upgraded, track the replacement in Salesforce on asset detail pages.
a. The Primary Assets related list shows assets that replaced the current asset.
b. The Related Assets related list shows assets that the current asset replaced.
6. You can create asset hierarchies to represent products with multiple components, and view a tree grid of an asset’s hierarchy on its detail page. On the support side, assets can be linked to cases, work orders, maintenance plans, entitlements, and contract line items, making it easy to see an asset’s history from production to retirement.

2. What counts towards API usage in Salesforce?

Any action that sends a call to the API counts toward usage limits, except the following

1. Outbound messages
2. Apex callouts

3. Considerations for Email Open Tracking

In Lightning Experience, email tracking applies to all emails and list emails sent through Salesforce, Office 365, Gmail, Email Relay, and Einstein Activity Capture.

Email tracking doesn’t apply to emails sent from Cases or emails that use Email-to-Case.

List emails show tracking information in the HTML Status Report only.

If the recipient field has an email address only, and no related contact, lead, or person account, it isn’t tracked.

If the body of an email is blank, it isn’t tracked.

If email tracking was enabled before, emails sent before Winter ‘19 don’t show the correct tracking information in Lightning Experience. The activity timeline and the email record home show Not Tracked for these emails. The correct tracking information is available in the HTML Status report.

4. What if the evaluation criteria is set to "Only when a record is created" in time-based Workflow?

In this case, the Workflow rule evaluates the time triggers only once. If the record that fired the rule changes and no longer meets the evaluation criteria, the pending actions are removed from the queue and the rule is never reapplied to the record.

All pending actions are evaluated only for as long as the rule criteria is true. While Salesforce evaluates the rule every time the record is updated, it does not trigger all the actions associated with the rule every time.

Example: Consider two rules that are identical, except the evaluation criteria of Rule 1 is "On create only" and Rule 2 is "When a record is created, and anytime it's edited to subsequently meet criteria."
If you create a record that matches both rules, Salesforce executes the immediate actions and queues the time-dependent actions of both rules. If you then update the record and it no longer meets the rule criteria, Salesforce removes the pending actions for both rules. If you then update the record so it meets the rule criteria again, Salesforce only executes the actions associated with Rule 2.

5. Enable Email Tracking for All Customers Opening Email from Your Company

Let sales reps see if and when customers open email sent through Salesforce. In Lightning Experience, reps see tracking info right in the activity timeline, and—if they aren’t using Einstein Activity Capture—in the HTML Email Status report. Salesforce Classic users see the indicators in a report or in a related list. This feature applies to all emails sent through Salesforce; it can’t be turned off for individual emails or customers.

Lightning Experience organizations must enable Enhanced Email.

From Setup, enter Activity Settings in the Quick Find box, then select Activity Settings.
Select Enable Email Tracking.
Click Submit.

6. Salesforce Change Data Capture notifications

1. If the record is updated without any field values changes, it sends notifications with LastModifiedDate.
2. If multiple records are updated on the same transaction without any field values changes, it sends one notification with recordIds attribute holding multiple ids.
3. If multiple records are updated on the same transaction with the same field values changed, it sends one notification with recordIds attribute holding multiple ids with field and its value.
3. If multiple records are updated on the same transaction with different field values changed, it sends multiple notifications with recordIds holding one Id and it's related field and its value.

7. Patch Releases and Daily Releases in Salesforce

Patch Releases and Daily Releases are used to deliver scheduled and ad hoc application fixes and are typically seamless to customers. Whenever possible, patches and daily releases are deployed during off-peak hours and without downtime. Patch releases are scheduled weekly and are usually deployed to instances on Tuesday, Wednesday or Thursday, with releases to Asia-Pacific instances the following day. Daily releases are conducted on an as-needed basis and can occur any day of the week.

For more information check the below link

8. How to create EmailMessage manually and link it to a record?

1. Create EmailMessage.
2. Create EmailMessageRelation to link it to the record using relationId field.

// if EnhancedEmail Perm is not enabled, continue logging the email as a task

// if EnhancedEmail Perm is enabled, create an EmailMessage object
EmailMessage emailMessage = new EmailMessage();
emailMessage.status = '3'; // email was sent
emailMessage.relatedToId = '006B0000003weZGIAY'; // related to record e.g. an opportunity
emailMessage.fromAddress = ''; // from address
emailMessage.fromName = 'Dan Perkins'; // from name
emailMessage.subject = 'This is the Subject!'; // email subject
emailMessage.htmlBody = '<html><body><b>Hello</b></body></html>'; // email body
// Contact, Lead or User Ids of recipients
String[] toIds = new String[]{'003B000000AxcEjIAJ'};
emailMessage.toIds = toIds;
// additional recipients who don’t have a corresponding contact, lead or user id in the Salesforce org (optional)
emailMessage.toAddress = ',';
insert emailMessage; // insert

// Add Email Message Relation for id of the sender
EmailMessageRelation emr = new EmailMessageRelation();
emr.emailMessageId =;
emr.relationId = '005B0000003qHvOIAU'; // user id of the sender
emr.relationType = 'FromAddress';
insert emr;

9. TIMEVALUE formula in Salesforce

TIMEVALUE function returns the time in GMT.

When the user select Date/Time field in Salesforce, they select it in their timezone. But, Salesforce saves that in GMT.

10. TLS 

Transport Layer Security (TLS), and its now-deprecated predecessor, Secure Sockets Layer (SSL),[1] are cryptographic protocols designed to provide communications security over a computer network.[2] Several versions of the protocols find widespread use in applications such as web browsing, email, instant messaging, and voice over IP (VoIP). Websites can use TLS to secure all communications between their servers and web browsers.

11. Function ISCHANGED 

ISCHANGED  function is available only in:

1. Assignment rules
2. Validation rules
3. Field updates
4. Workflow rules if the evaluation criteria are set to Evaluate the rule when a record is: created, and every time it’s edited.
5. Formula criteria for executing actions in Process Builder.
6. This function returns FALSE when evaluating any field on a newly created record.
7. If a text field was previously blank, this function returns TRUE when it contains any value.
8. For number, percent, or currency fields, this function returns TRUE when:
a. The field was blank and now contains any value
b. The field was zero and now is blank
c. The field was zero and now contains any other value

12. How to override New button in Salesforce Lightning Experience?

Use lightning:actionOverride in the aura:component to override standard actions in Salesforce Lightning Experience.

Sample Code -

13. Manage Sharing permission on the profile in Salesforce

It allows the user to manage sharing configurations, including Organization-wide defaults.

14. What happens when a parent object permission is set to private and child object permission is set to public read-only or public read/write?

Users with Read access on Child objects can view all child records even though they don't have access to the parent records. They can also view to which parent record it is related to.
Users with Edit access on Child objects can edit all child records.
Users can view parent records if they are the owner or they get sharing through role hierarchy, manual sharing, etc.

15. Phone No and Email fields in Task and Event objects in Salesforce

Phone No and Email fields in Task and Event objects in Salesforce are not editable and are auto-populated from the associated contact or lead record.
These are special fields as they pull the information of Phone and Email from either Contact or Lead.
It contains the phone number of the contact or lead related to the task. This field is filled in with the value from the related contact or lead record.

16. Login Flows

Manage your login flows. Use login flows to introduce business processes during login, such as to prompt for two-factor identification, accept terms of service, or collect information about the user. After users complete the login flow, they're logged in. This page lists available login flows and the user profile associated with each.

17. Sample Builder Pattern in Salesforce

The Builder is a design pattern designed to provide a flexible solution to various object creation problems in object-oriented programming. The intent of the Builder design pattern is to separate the construction of a complex object from its representation.

For more information and a useful example on the Builder Pattern see

18. How to test scheduled actions from the Process builder using Test class?

Test.stopTest() executes scheduled actions for record-change processes and event processes (built-in Process Builder) and resumes flow that is waiting for time-based resume events.

19. How to ensure Field Level Security in SOQL in Salesforce?

Use the WITH SECURITY_ENFORCED clause to enable field and object-level security permissions checking for SOQL SELECT queries in Apex code, including subqueries and cross-object relationships.

If any fields or objects referenced in the SOQL SELECT query using WITH SECURITY_ENFORCED are inaccessible to the user, an exception is thrown, and no data is returned.

If field access for either LastName or Description is hidden, this query throws an exception indicating insufficient permissions.
view source print?

List<Account> act1 = [SELECT Id, (SELECT LastName FROM Contacts),
   (SELECT Description FROM Opportunities)

The WITH SECURITY_ENFORCED clause is only available in Apex. Using WITH SECURITY_ENFORCED in Apex classes or triggers with an API version earlier than 45.0 is not recommended.

20. How to add value to a specific array or list index using apex in Salesforce?

List < String > strList = new List < String >();
strList.add( 'Test 0' );
strList.add( 'Test 1' );
strList.add( 'Test 2' );
system.debug( 'Value in 1st block is ' + strList.get( 1 ) );//Test 1
strList.add( 1, 'Sample 1' );
system.debug( 'Value in 1st block is ' + strList.get( 1 ) );//Sample 1

21. Salesforce Extensions for Visual Studio (VS) Code

Salesforce Extensions for VS Code is built on top of Salesforce CLI and VS Code. Together, they are an integrated development environment that’s created for custom development on Lightning Platform. Best of all, you can run Salesforce CLI commands directly from the command palette or terminal.

22. controller attribute in aura:component tag

The server-side controller class for the component in the format namespace.myController or myController if using the default namespace.
We can refer only one apex class.

Referencing multiple Server-Side Apex controllers Classes within a Lightning Component is not supported.

23. Related To field is not editable in Salesforce

Related To indicates the record that the task is related to, such as an account or an opportunity. This field is available only when a user relates the task to a contact, not to a lead. The record is visible only to users with the “Read” permission for the type of record the task is related to.

You can’t relate an account, opportunity, or other objects to a task already related to a lead.

If a user relates the task to an object other than an account, Salesforce determines the account on the task as follows.

Suppose that a user relates the task to an opportunity, a contract, or a custom entity that belongs to an account. Salesforce uses that object’s account as the account for the task.
Suppose that a user relates the task to some other object and also to contact. Salesforce uses the primary contact’s account as the account for the task.
If a user leaves the Related To field empty, Salesforce doesn’t relate an account to the task.

24. 'Callout from triggers are currently not supported' error in Salesforce

In certain scenarios, we need to make the callout from the trigger to call an external web service however we are not able to do so as it gives the below-mentioned error "Callout from triggers is currently not supported".

An Apex trigger can execute a callout when the callout is invoked within a method defined as asynchronous: that is, defined with the @future keyword. The @future annotation signifies that the Apex method executes asynchronously.

Callouts must be made asynchronously from a trigger so that the trigger process isn’t blocked while waiting for the external service's response. The asynchronous callout is made in a background process, and the response is received when the external service returns it. To make an asynchronous callout, use asynchronous Apex such as a future method.

The best practice is to call future callout method on after insert and after update events.

25. SOQL with parent field reference

Always use Parent Id instead of Parent.Id.
Use AccountId instead of Account.Id in the Query.

Use inner join query instead of using Parent object field reference. Make sure the parent object field is indexed for selective.
List < Contact > listContacts = [ SELECT Id FROM Contact WHERE Account.Name = 'Test' ];//Takes more time to execute
List < Contact > listContacts1 = [ SELECT Id FROM Contact WHERE AccountId IN ( SELECT Id FROM Account WHERE Name = 'Test') ];//Takes less time to execute

26. Chatter Usage impact on Data Storage in Salesforce 

Chatter feed posts and comments are not counted against your data storage limits.

File storage includes files in attachments, Files home, Salesforce CRM Content, Chatter files (including user photos), the Documents tab, the custom File field on Knowledge articles, and assets.

Reference Link

27. 'Top Results' in Salesforce Lightning Experience Global Search

In Lightning Experience, each user's Top Results page includes the objects they use the most.
For new users or users that have little to no activity in Salesforce for over 90 days:

- Default global search in Classic returns all objects (same results as clicking 'Search All').

- Default 'Top Results' in Lightning returns the objects that are set in the current Lightning App's navigation menu

28. Trigger.size in Salesforce trigger

The total number of records in a trigger invocation, both old and new.

29. How to deploy Field Set using Apache ANT tool in Salesforce?


30. Formula Field and Parent record value in the trigger

In trigger context, you can reach only fields from the processed object level. This means no relation fields are available. Although you can get those values in 3 ways - either use SOQL query, formula field or workflow.

31. How to join a list of strings with a separator using Apex in Salesforce?

List < String > strList = new List < String > { 'Test 1', 'Test 2', 'Test 3' };
String str = String.join( strList, ', ' );
system.debug( 'Joined with coma is ' + str );//Test 1, Test 2, Test 3

32. Running user of Platform Events subscribers in Salesforce

Unlike triggers on standard or custom objects, triggers on platform events don’t execute in the same Apex transaction as the one that published the event. The trigger runs in its own process under the Automated Process entity, which is a system user.

33. 'Reload' button under Bulk Data Load Jobs in Salesforce

The reload button refreshes the page of the under bulk data load jobs on its current state which is the status of the import. It does not redo the import and has the sole purpose of refreshing the page.

34. Security and the PushTopic Query

Subscribers receive notifications about records that were created, updated, deleted, or undeleted if they have:
Field-level security access to the fields specified in the WHERE clause
Read access on the object in the query
Read access on the PushTopic
Visibility of the new or modified record based on sharing rules
If the subscriber doesn’t have access to specific fields referenced in the query SELECT clause, then those fields aren’t included in the notification. If the subscriber doesn’t have access to all fields referenced in the query WHERE clause, then they will not receive the notification.

For example, assume a user tries to subscribe to a PushTopic with the following Query value:

SELECT Id, Name, SSN__c
  FROM Employee__c
 WHERE Bonus_Received__c = true AND Bonus_Amount__c > 20000
If the subscriber doesn't have access to Bonus_Received__c or Bonus_Amount__c, the subscription fails. If the subscriber doesn’t have access to SSN__c, then it won’t be returned in the notification.

If the subscriber has already successfully subscribed to the PushTopic, but the field-level security then changes so that the user no longer has access to one of the fields referenced in the WHERE clause, no streamed notifications are sent.

No comments:

Post a Comment