format()
will remove the time stamp from Date.
Here is an example:
Date dt = System.Today();
Date newdt = dt.format();
substringAfter()
is used to find substring of a string, after particular character using Apex in Salesforce.
Here is an example:
String name = 'Biswajeet-Samal';
String result = name.substringAfter('-');
right()
is used to get last n digits from a String using Apex.
Here is an example:
String str = 'biswajeet';
String result = str.right(4); //returns jeet
toLabel()
is used to convert the results of a field into user’s language.
toLabel()
can convert the results into user’s language, if the translation workbench is enabled.
- In all Salesforce edition we can use
toLabel()
.
- For picklist and Record type values we can use the
toLabel()
function in SOQL.
Here is an example:
SELECT Name, toLabel(Industry) FROM Account
Result:
Sometimes we need “NOT LIKE” operator in SOQL.
But SOQL will not allow someone to write simple query using “Not Like” operator such as:
SELECT Name From Account Where Name Not Like '%Test%';
So, here is the solution:
SELECT Name From Account Where Not Name Like '%Test%';
If you are using “GROUP By” clause with “Not Like” operator, here is an example:
SELECT Name From Account Where Not Name Like '%Test%' Group By Name;