Salesforce Interview Questions with Answers Part 69

1. Polymorphic Field in SOQL Queries in Salesforce

2. What is the advantage of using Continuation in Salesforce?
Use the Continuation class in Apex to make a long-running request to an external Web service. Process the response in a callback method. An asynchronous callout made with a continuation doesn’t count toward the Apex limit of 10 synchronous requests that last longer than five seconds.

3. Limitations in Future methods
1. Only 10 future calls per Apex transaction are allowed.
2. A future call cannot make another future call.
3. Future calls cannot be guaranteed to run in a certain order.
** For 2 and 3, Queueable interface is the alternative for this where we can chain the jobs.
4. The maximum number of future method invocations per a 24-hour period is 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater. This limit is for your entire org and is shared with all asynchronous Apex: Batch Apex, Queueable Apex, scheduled Apex, and future methods.
https://help.salesforce.com/s/articleView?id=000329529&type=1

4. Connection pool
In software engineering, a connection pool is a cache of database connections maintained so that the connections can be reused when future requests to the database are required. Connection pools are used to enhance the performance of executing commands on a database. Opening and maintaining a database connection for each user, especially requests made to a dynamic database-driven website application, is costly and wastes resources. In connection pooling, after a connection is created, it is placed in the pool and it is used again so that a new connection does not have to be established. If all the connections are being used, a new connection is made and is added to the pool. Connection pooling also cuts down on the amount of time a user must wait to establish a connection to the database.

5. What is the default Timeout value in Connected App if it is Blank?
Salesforce Access Token Expiry:

Under Session Policies, click the Timeout Value dropdown menu and select when access tokens expire for a user’s connected app session.

You can control how long a user’s session lasts by setting the timeout value for the connected app, user profile, or org’s session settings (in that order). If you don’t set a value or you select None (the default), Salesforce uses the timeout value in the user’s profile. If the user’s profile doesn’t specify a timeout value, Salesforce uses the timeout value in the org’s Session Settings. The current permissions for the connected app are also listed in the org’s Session Settings.

Reference Artilce:
https://help.salesforce.com/s/articleView?id=sf.connected_app_manage_session_policies.htm&type=5

6. Changing Relationship field in Salesforce
a. You can convert a master-detail relationship to a lookup relationship as long as no roll-up summary fields exist on the master object.
b. Converting a master-detail relationship to a lookup for a custom object on the “detail” side, changes the organization-wide default for the object to public read/write.
c. You can convert a lookup relationship to a master-detail relationship if the lookup field in all the records contains a value.
d. A lookup relationship can’t be changed to a master-detail relationship if the organization-wide default of the child object access level in the relationship is Controlled by Parent.
e. Converting a lookup to a master-detail-relationship changes the organization-wide default to Controlled by Parent and the sharing model is updated to public read/write.
Reference article:
https://help.salesforce.com/s/articleView?id=sf.relationships_considerations.htm&type=5

7. Restriction Rule in Salesforce
Use restriction rules when you want certain users to only see a specific set of records. Filter records based on User and Record criteria.

8. Database.getUpdated using Apex in Salesforce
Syntax:
Database.GetUpdatedResult r = Database.getUpdated(
    'Object API Name',
    StartDateTime,
    EndDateTime
);

Sample Code:

Database.GetUpdatedResult r = Database.getUpdated(
    'Account',
    Datetime.now().addDays( -1 ),
    Datetime.now()
);
System.debug( 'Updated Records result is ' + r );

To get Ids:
Database.GetUpdatedResult r = Database.getUpdated(
    'Account',
    Datetime.now().addDays( -1 ),
    Datetime.now()
);
System.debug( 'Updated Accounts Ids are ' + r.getIds() );

9. Record access when using Master Detail relationship in Salesforce
We cannot set sharing and permissions for the Master and Detail objects separately. 
 
Detail and subdetail(parent and child) records inherit security settings and permissions from the master(parent) record. You can’t set permissions on the detail record independently. 

10. Asynchronous Processes in Salesforce
The maximum number of Asynchronous Processes per a 24-hour period is 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater.

Asynchronous Apex: Batch Apex, Queueable Apex, scheduled Apex, and future methods.

Sample Code to check the limit:
Map < String,System.OrgLimit > limitsMap = OrgLimits.getMap();
System.OrgLimit apiRequestsLimit = limitsMap.get( 'DailyAsyncApexExecutions' );
System.debug( 'Limit Name: ' + apiRequestsLimit.getName() );
System.debug( 'Usage Value: ' + apiRequestsLimit.getValue() );
System.debug( 'Maximum Limit: ' + apiRequestsLimit.getLimit() );

11. Two type of Quick Action using Lightning Web Component
a. Screen
It will popup the component.
b. Action
It won't popup the component. invoke() method will be called.

12. Standard Junction objects in Salesforce:
1. Case Article(CaseArticle)
2. Opportunity Product(OpportunityLineItem)
3. Pricebook Entry(PriceBookEntry)
4. Opportunity Contact Role(OpportunityContactRole)
5. Account Contact Role(AccountContactRole)
6. Account Team(AccountTeamMember)
7. Case Team(CaseTeamMember)
8. Opportunity Team(OpportunityTeamMember)

13. Difference between Tree and Tree Grid in Salesforce Lightning Web Component(LWC)
Tree

Displays a nested tree.
A simple tree with several levels that you can expand and collapse.

Tree Grid
Displays a hierarchical view of data in a table.
A tree grid displays structured data in a table with expandable rows.

14. Transaction Finalizers in Salesforce Queueable Interface
The Transaction Finalizers feature enables you to attach actions, using the System.Finalizer interface, to asynchronous Apex jobs that use the Queueable framework. A specific use case is to design recovery actions when a Queueable job fails.

Sample Use Cases:
1. Retry in FinalizerContext if the queueable job fails
2. Add error log record in FinalizerContext to report on failures

Sample Class:
public class SampleClass implements Finalizer, Queueable {

    public void execute( QueueableContext ctx ) {
    }

    public void execute( FinalizerContext ctx ) {
    
        String parentJobId = '' + ctx.getAsyncApexJobId();   

        if ( ctx.getResult() == ParentJobResult.SUCCESS) {
       
            System.debug('Parent queueable job [' + parentJobId + '] completed successfully.');
           
        } else {
       
            System.debug( 'Parent queueable job [' + parentJobId + '] failed due to unhandled exception: ' + ctx.getException().getMessage() );            
           
        }
       
    }
    
}


15.What is the difference between SFDX: Create Project and SFDX: Create Project with Manifest in Salesforce CLI?
SFDX: Create Project:
This creates an empty project with just the folders.
To develop in non-scratch orgs and use Org Browser to retrieve source, use SFDX: Create Project.

SFDX: Create Project with Manifest
This creates a project with a folder called Manifest. The Manifest folder will have default Package.xml. The Package.xml will contain minimum metadata types for the developer to start working.
When you run SFDX: Create Project with Manifest command, a package.xml file is created. Add the various metadata types you want to retrieve to this file.