How to Clone Sandbox in Salesforce?

1. Go to Sandboxes.


2. Click Clone link to clone the sandbox.


Cheers!!!

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.

Sample Code:
BusinessHours bh = [SELECT Id FROM BusinessHours WHERE IsDefault = true];
Datetime nextStart = BusinessHours.nextStartDate(bh.id, system.today());
system.debug('Next Start Date is ' + nextStart);

If you execute the above code within the business hours(example if the business hours is 9 am to 6 pm and execute within the time frame), then it will return today's date.

If you execute the above code outside the business hours(example if the business hours is 9 am to 6 pm and execute outside the time frame), then it will return next open business date.

Cheers!!!

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.

Sample Code:

trigger CaseTrigger on Case (before insert) {
    
    Boolean tomorrowTargetBool = system.now().hour() >= 12 ? true : false;
    for ( Case c : trigger.new ) {
        if ( tomorrowTargetBool ) 
            c.Target_Date__c = system.today() + 1;
    }
    
}

In the above example, if the case is created after 12 PM, the target date field will be next day.

Cheers!!!

How to avoid or reduce SOQLs in Salesforce?

1. Do not use SOQL inside the for loop.

2. User UserInfo wherever possible - http://www.infallibletechie.com/2016/01/how-to-get-username-of-user-using-apex.html.

3. Use Custom Settings for hard coding Report Folder or Dashboard Folder ids, Email Templates ids, Public Group ids, Field ids, etc.

4. Use @future methods or queueable interface.

http://www.infallibletechie.com/2012/08/future-annotation-in-salesforce.html

http://www.infallibletechie.com/2016/08/queueable-apex.html

5. Avoid triggers from firing again and again - http://www.infallibletechie.com/2014/05/how-to-avoid-recursive-trigger-in.html.

6. Use trigger instead of workflow rules and process builders since they are not bulkified.

7. Use schema instead of query to get record type, etc - http://www.infallibletechie.com/2014/03/how-to-get-recordtypeid-using-record.html.

Cheers!!!

Salesforce Interview Questions with Answers Part 49

1. What is a Mashup?

http://www.infallibletechie.com/2018/01/what-is-mashup.html

2. What is JSON?

http://www.infallibletechie.com/2018/01/what-is-json.html

3. Force.com Streaming API

http://www.infallibletechie.com/2015/03/forcecom-streaming-api.html

4. Salesforce APIs and supported formats

http://www.infallibletechie.com/2018/01/salesforce-apis-and-supported-formats.html

5. What is a PushTopic?

http://www.infallibletechie.com/2018/01/what-is-pushtopic.html

6. What is WSDL?

http://www.infallibletechie.com/2018/01/what-is-wsdl.html

7. SOAP API Methods using WSDL from Salesforce

http://www.infallibletechie.com/2018/01/soap-api-methods-using-wsdl-from.html

8. Difference between SOAP and REST APIs

http://www.infallibletechie.com/2014/03/blog-post.html

9. HTTP Methods available in Salesforce

http://www.infallibletechie.com/2018/01/http-methods-available-in-salesforce.html

10. What is the use of done attribute in Salesforce REST API response?

http://www.infallibletechie.com/2018/01/what-is-use-of-done-attribute-in.html

11. What is the Chatter REST API?

http://www.infallibletechie.com/2018/01/what-is-chatter-rest-api.html

12. Lock Contention

http://www.infallibletechie.com/2018/01/lock-contention.html

13. How to limit maximum number of characters that can be typed into ui:inputText and other input fields in Lightning Components?

http://www.infallibletechie.com/2018/01/how-to-limit-maximum-number-of.html

14. Cross-Org Adapter for Salesforce Connect

https://help.salesforce.com/articleView?id=xorg_adapter_about.htm&type=5

15. Continuation Class

Use the Continuation class to make callouts asynchronously to a SOAP or REST Web service.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Continuation.htm#apex_class_System_Continuation

16. How to avoid or reduce SOQLs in Salesforce?

http://www.infallibletechie.com/2018/02/how-to-avoid-or-reduce-soqls-in.html

Cheers!!!