Salesforce
Salesforce User Experience:
Salesforce classic – It’s an old age UI. With Salesforce classic, you need to use
Visualforce (which is a Salesforce proprietary language) that you can use to build
your UI pages.
Salesforce Lightning – It’s a Morden UI. You can see all the related records on the
right side of the same page. With Salesforce Lightning, you can use 2 technologies:
a. Aura components: Introduced in 2014 and it is more mature than Lightning web
component.
b. Lightning web components: Introduced in 2018.
Note: Although both are similar components but they are different in tech stack. Lightning
web component is much faster than the Aura component because it is based on latest web
standards so that it can easily communicate easily with your web browser; whereas Aura
component is completely Salesforce proprietary framework.
Note: Salesforce uses Oracle database as a backend.
Apex is a proprietor language of Salesforce. It is 90% similar to the Java. It is object-oriented
programming language. Apex is saved, complied and executes on the servers of force.com
platform. Apex is a case-insensitive language.
String Classes:
String st = ' i am a disco dancer ';
Integer inte = 123;
System.debug('Capital letter = '+st.capitalize());
System.debug('Contains ring? = '+st.contains('isco'));
System.debug('String to Upper case = '+st.toUpperCase());
System.debug('String to Lower case = '+st.toLowerCase());
System.debug('Is equal to disco? = '+st.equals('disco'));
String str1 = 'Manish';
String str2 = 'manish';
System.debug('Is String1 equals to String2 = '+str1.equals(str2));
System.debug('Is String1 equals to String2 = '+str1.toLowerCase().equals(str2));
System.debug('Index of = '+st.indexOf('a'));
System.debug('Length of String = '+st.length());
System.debug('Remove character = '+st.remove('disco'));
System.debug('Remove character = '+st.remove('a'));
System.debug('Replace word = '+st.replace('disco','sexy'));
System.debug('Reverse word = '+st.reverse());
System.debug('Split the words = '+st.split(' '));
System.debug('Trim the word = '+st.trim());
String strr = String.valueOf(inte);
System.debug('Convert Int to String = '+strr);
For apostrophe: String str = 'My team\'s name is \'SFDC Academy\' \n we work in Apex';
Multi- Tenant Environment: Means Single resource is being shared or run on multiple
environments.
SOQL & SOSL: If you want to get the data from the database though Apex program then you
use these SOQL & SOSL. Salesforce Object Query Language (SOQL) and it’s similar to SQL.
Salesforce Object Search Language (SOSL) and it is used for text base searching on records.
DML & Database class: If we want to create, update and delete any record in database then
we use DML & Database class.
Note: We cannot create/write Apex code in Production environment because live users are
accessing the environment that time. We write the code in development environment. We
get 2 kind of developer environments:
1. Developer Edition is a free fully featured environment of Salesforce. Limitation of
Developer Edition are: Only 5 MB data storage and 5000 API calls every 24 hours and
provides only 2 licences.
2. Sandbox Copy of Production environment is called Sandbox.
We can run apex in developer org, production org and a sandbox.
Different tools for writing Apex Code:
1. Force.com Developer console: It’s a browser-based IDE. The Developer console is an
integrated environment where we can create, debug and test the applications in our
Salesforce.org
2. Force.com IDE: It is a plugin for Eclipse IDE which provide an interface for building
and deploying the Force.com application.
3. Code Editor in Salesforce Interface: This code editor complies all the classes and
triggers and flag some error if any.
Note: The code doesn’t get saved until it complies without error. The Force.com Developer
console and Force.com IDE allow you to write, test and debug the Apex code. On the other
hand, Code Editor enable only to write the code’ it does not support debugging & testing.
Note: A new UI of Salesforce called, Salesforce Lightning. If you want to build Salesforce
Lightning UI then you have 2 technologies here:
Aura component framework (Old framework and bit slower)
Lightning Web components (New framework and much faster because it is based on
latest web standard)
Declarative tools in Salesforce:
1. Workflow rule: Send email & Outbound Message, Create task, Update record, No
Child record update.
2. Process Builder: Multiple Steps, more actions, Child record update, cannot delete a
record.
3. Visual Flow: Most powerful declarative tool, Executing is slower than Apex,
Debugging can be difficult sometimes.
List collection: An ordered collection of elements of same data types. It allows duplicate
data. List accepts multiple null values.
new keyword is used to create an instance of a class and allocate a memory. List always
starts with index 0.
Set collection: An ordered collection of elements of same data types. It doesn’t allow
duplicate data. Set accept null values but only once.
Map collection: Map is another collection and it store the data in key & value pair. If both
keys are same then Map will override the value to last the value.
Print Lists in Map:
//Post for Apex Category
List<String> apexPost = new List<String>{'Demystifying Apex Collections', 'Datatypes and variables in Apex'};
//Post for Lighting Category
List<String> lightPost = new List<String>{'Events in Aura framework', 'Developing reusable components'};
//Map is using to store the lists
Map<String, List<String>> allPost = new Map<String, List<String>>();
allPost.put('Apex',apexPost);
allPost.put('Lighting',lightPost);
System.debug(allPost);
Constant variables: Once you initialized, a Constant variable does not change its value using
final keyword. Ex. Final Integer Pi = 3.141;
Operators
Problem statement
Q. How to convert your data types? i.e. String to Integer.
Sol: Integer sum = Integer.valueOf(‘5’);
Note: In Switch When case statement you can pass null value.
If Else statement
Switch when statement: We can’t give condition in switch when statement.
Leap year Program
Leap year program with do while loop
Problem Statement
Leap year program with while loop
Star pattern