Another Salesforce blog!!!

Salesforce, Apex


using string literals

Literal strings must be enclosed in single quotation marks. double quotation marks are reserved for enclosing attribute values, and must be escaped in strings. Use the “\” character to escape strings. Favorite

lock record using SOQL so that it cannot be modified by other user

we will need “FOR UPDATE” clause of SOQL. Account[] accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE]; Favorite

SOQL statement can be used to get all records even from recycle bin

We will need “ALL Rows” clause of SOQL. SELECT COUNT() FROM Contact WHERE AccountId = a.Id ALL ROWS Favorite