Salesforce Interview Questions with Answers Part 51

Salesforce Interview Questions with Answers Part 51

1. How to get the current hour in the local time zone of the context user using apex in Salesforce?

hour() returns the hour component of a Datetime in the local time zone of the context user.

https://www.infallibletechie.com/2018/02/how-to-get-current-hour-in-local-time.html

2. What is the use of nextStartDate?

Starting from the specified target date, returns the next date when business hours are open. If the specified target date falls within business hours, this target date is returned.

https://www.infallibletechie.com/2018/02/what-is-use-of-nextstartdate.html

3. Types of events in Lightning in Salesforce

Component events are handled by the component itself or a component that instantiates or contains the component.
Application events are handled by all components that are listening to the event. These events are essentially a traditional publish-subscribe model.

4. Lightning Data Service

Use Lightning Data Service to load, create, edit, or delete a record in your component without requiring Apex code. Lightning Data Service handles sharing rules and field-level security for you. In addition to not needing Apex, Lightning Data Service improves performance and user interface consistency.

Examples:

https://www.infallibletechie.com/2017/11/forcecreaterecord-example-in-salesforce.html

https://www.infallibletechie.com/2018/02/forceeditrecord-example-in-salesforce.html

5. What is Concurrent Request Limit in Salesforce?

Once a synchronous Apex request runs longer than 5 seconds, it begins counting against this limit. Each organization is allowed 10 concurrent long-running requests. If the limit is reached, any new synchronous Apex request results in a runtime exception. This behavior occurs until the organization’s requests are below the limit.

Some useful tips:

a. Convert synchronous processes to asynchronous processes. Batch Apex might be a viable alternative. Limit synchronous Web service callouts.
b. Use the Streaming API instead of polling
c. Tune SOQL and DML operations. Make sure that your queries are selective. Limit the number of records in your list views. Avoid data skew.

6. What is the use of Individual object and how to enable it?

Represents a customer’s data privacy and protection preferences. Data privacy records based on the Individual object store customer’s privacy preferences and are associated with a lead or a contact.

https://www.infallibletechie.com/2018/03/what-is-use-of-individual-object-and.html

7. With SeeAllData=true, will changes to live data be visible to the user?

No. Only the test method will see those changes, because an incomplete transaction is “isolated” from the rest of the database. This means that at no point will the changes made in the test method will be visible to any user.

8. How to navigate from one component to the other component in Salesforce lightning?

force:navigateToComponent can be used.

Sample Code – https://www.infallibletechie.com/2018/03/lightning-component-navigation-in.html

9. force:hasRecordId

Add the force:hasRecordId interface to a Lightning component to enable the component to be assigned the ID of the current record. The current record ID is useful if the component is used on a Lightning record page, as an object-specific custom action or action override in Lightning Experience or the Salesforce app, and so on.

If your component implements force:hasRecordId, you don’t need to add a recordId attribute to the component yourself. If you do add it, don’t change the access level or type of the attribute or the component will cause a runtime error.

The recordId attribute is set only when you place or invoke the component in an explicit record context. For example, when you place the component directly on a record page layout, or invoke it as an object-specific action from a record page or object home. In all other cases, such as when you invoke the component as a global action, or create the component programmatically inside another component, recordId isn’t set, and your component shouldn’t depend on it.

https://www.infallibletechie.com/2018/03/forcehasrecordid-in-custom-lightning.html

10. What is the use of Time-Based Workflow under Monitor in Setup?

Time-Based Workflow shows only pending actions and allow us to cancel them if necessary.

11. Why trigger over workflow field update and process builder?

If field update is done using Process builder, then record will go through complete Save cycle again.

If field update is done using Workflow field update, then Custom validation rules, duplicate rules, and escalation rules will not run again.

If trigger is already written then instead of creating workflow or process builder field update, it is best to use existing trigger for field update. Multiple execution of trigger could cause hitting various governor limits like SOQL query or concurrent apex limit.

12. How to secure Outbound Message in Salesforce?

You configure an outbound message to include a sessionId and specify a user in the User to send as field. The user doesn’t have outbound messaging disabled.

Your application (endpoint) server’s SSL/TLS may be configured to require client certificates (two-way SSL/TLS), in order to validate the identity of the Salesforce server when it takes the role of client to your server. If this is the case, you can download the Salesforce client certificate from the Salesforce application user interface. This is the client certificate that Salesforce sends with each outbound message for authentication.

a. Go to API.
b. On the API WSDL page, click Manage API Client Certificate.
c. On the Certificate and Key Management page, in the API Client Certificate section, click the API Client Certificate.
d. On the Certificates page, click Download Certificate. The .crt file is saved in the download location specified in your browser.
e. Import the downloaded certificate into your application server, and configure your application server to request the client certificate. The application server then checks that the certificate used in the SSL/TLS handshake matches the one you downloaded.


13. Use of Documentation in Lightning Bundle in Salesforce

description is to show the description of the component. example is to show look and feel of the component.

The documentation you create will be available at https://<myDomain>.lightning.force.com/auradocs/reference.app, where <myDomain> is the name of your custom Salesforce domain and in the Component Library (Beta) at https://<myDomain>.lightning.force.com/componentReference/suite.app where <myDomain> is the name of your custom Salesforce domain.

https://www.infallibletechie.com/2018/04/documentation-in-lightning-bundle-in.html

14. Use of SVG in Lightning Component Bundle

You can use an SVG resource to define a custom icon for your component when it appears in the Lightning App Builder’s component pane. Include it in the component bundle.

https://www.infallibletechie.com/2018/04/svg-in-lightning-component-bundle.html

15. $A.getCallback()

Use $A.getCallback() to wrap any code that modifies a component outside the normal rerendering lifecycle, such as in a setTimeout() call. The $A.getCallback() call ensures that the framework rerenders the modified component and processes any enqueued actions.

https://www.infallibletechie.com/2018/04/agetcallback-usage-for-polling-in.html

16. Difference between Database.query() and Database.getQueryLocator

https://www.infallibletechie.com/2013/05/difference-between-databasequery-and.html

17. What happens when SELECT COUNT() FROM Employee__c is executed in a trigger for a user who doesn’t have access to Employee object?

It will return the no of records in the employee object.

18. What happens when SELECT COUNT() FROM Employee__c is executed in a trigger handler with “with sharing” keyword for a user who doesn’t have access to Employee object?

It will return 0.

19. What happens when SELECT COUNT() FROM Employee__c is executed in a trigger handler with “without sharing” keyword or with no sharing keyword(public class classname) for a user who doesn’t have access to Employee object?

It will return the no of records in the employee object.

Leave a Reply