Concepts or coding lessons of Salesforce that you can implement easily

How to convert 15 to 18 digit Id using apex in Salesforce?

Here is the simple way to convert Salesforce 15 digit ID into 18 digit:

String fifteenDigit = '500i0000006oHua'; // Your 15 digit salesforce Id
Id eighteenDigit = fifteenDigit;        
System.debug('15 Digit Id is => ' + fifteenDigit);
System.debug('18 Digit Id is => ' + eighteenDigit);

Output:

15 Digit Id is 500i0000006oHua
18 Digit Id is 500i0000006oHuaAAE



Read More: Which Salesforce API Do I Use in Integration?
                    When To Use Salesforce REST API  
                   When To Use Salesforce SOAP API 
                   When To Use Salesforce Bulk API 
                   When To Use Salesforce Chatter API  

5 Simple Steps to Delete Salesforce Org



I have created a Salesforce Developer org to learn Salesforce functionality. But there is no easy way to reset to default configurations, it seems to delete the current and apply a new one is the easiest solution.

To delete Salesforce developer org, you have to below steps:

1: Go to Setup.
2: Search for "Company Information". 
3: There is a Deactivate Org button in this configuration page, click on it.
4: Enter Your Org Name
5: Click on Deactivate Org Button.

First  30 Days: You can change your mind during this time and reactivate the Org.
Second 30 Days: The org is locked and you must contact Salesforce Customer Support to reactivate it.
After 60 Days: The org is permanently deleted and irretrievable.

The permanent delete takes 60 days. You may reactivate within 30 days and contact support after 30 days but within 60 days.


Read More: Which Salesforce API Do I Use in Integration?
                    When To Use Salesforce REST API  
                   When To Use Salesforce SOAP API 
                   When To Use Salesforce Bulk API 
                   When To Use Salesforce Chatter API  

Select * from X on apex (SOQL) in Salesforce

public static SObject[] selectAll(String objName,  String additionalFilters){
        
        //get object fields
        List<String> fieldList = new List<String>(Schema.getGlobalDescribe()
                               .get(objName).getDescribe().fields.getMap().keySet());
        String fields = String.join(fieldList,',');
        
        return (SObject[])Database.query(
          'SELECT '+fields+' FROM '+objName+ ' '+additionalFilters
        );
    } 
System.debug( Helper.selectAll('Account', 'Order by CreatedDate Limit 10')); 


Read More: Which Salesforce API Do I Use in Integration?
                    When To Use Salesforce REST API  
                   When To Use Salesforce SOAP API 
                   When To Use Salesforce Bulk API 
                   When To Use Salesforce Chatter API  

Skinny Tables Consideration in Salesforce


People sometimes mistake skinny tables as a convenient means of remedying performance issues, but skinny tables might not accommodate all use cases, or improve performance more than reading from the base Salesforce object with efficient indexes. 
They come with “side effects” that you should understand, as they might restrict or burden your business processes.

Before implementing skinny tables, consider the following.

1. Skinny tables are skinny. To ensure optimal performance, they contain only the minimum set of fields required to fulfill specific business use cases. If you later decide to add a field to your report or SOQL query, contact salesforce.com Customer Support to re-create the table.

2. You might think, “Why not just add all the fields at the beginning to get around the previous limitation?” Salesforce.com can add up to only 100 fields, and those fields must be of a certain type. 
For example, formula fields, fields derived from other objects (i.e., through lookup fields), and large CLOB fields cannot be added—if they were, we wouldn’t be calling skinny tables “skinny” at all.

Check out Benefits of Using Skinny Tables In Salesforce here !!!

3. Skinny tables don’t get copied over to sandbox organizations. This limitation might not be an issue for you, but to keep your production and sandbox environments consistent, you must track your changes and work with salesforce.com Customer Support to keep your environments in sync.

4. Skinny tables are custom tables in the underlying Force.com database. They don’t have the dynamic metadata flexibility you find in the base object. If you alter a field type (e.g., change a number field to a text field) the skinny table becomes invalid, and you must contact salesforce.com Customer Support to create a new skinny table.


Read More: Which Salesforce API Do I Use in Integration?
                    When To Use Salesforce REST API  
                   When To Use Salesforce SOAP API 
                   When To Use Salesforce Bulk API 
                   When To Use Salesforce Chatter API  

Benefits of Using Skinny Tables In Salesforce



1. A skinny table is a custom table in the Force.com platform that contains a subset of fields from a standard or custom base Salesforce object. Force.com can have multiple skinny tables, if needed, and maintains them under the hood and keeps them completely transparent to you.

2. By having narrower rows and less data to scan than the base Salesforce object, skinny tables allow Force.com to return more rows per database fetch, increasing throughput when reading from a large object, as this diagram shows.

3. Furthermore, skinny tables do not include soft-deleted rows (i.e., records in the Recycle Bin with isDeleted = true), which could also reduce the table volume in some cases. Custom indexes on the base table are also replicated, and they usually perform better because of the reduced table joins that happen in the underlying database queries.

4. The Force.com platform automatically synchronizes the rows between the base object and the skinny table, so the data is always kept current. The Force.com platform determines at query runtime when it would make sense to use skinny tables, so you don’t have to modify your reports or develop any Apex code or API calls.




Read More: Which Salesforce API Do I Use in Integration?
                    When To Use Salesforce REST API  
                   When To Use Salesforce SOAP API 
                   When To Use Salesforce Bulk API 
                   When To Use Salesforce Chatter API