SlideShare a Scribd company logo
1 of 6
--------------
EMAIL TEMPLATE
--------------
1. When we are using Text Email Template then the body of template comes in the
"body" field of the template and can be replaced.
We will use "mail.setPlainTextBody(body)"
2. When we are using HTML Email Template then the body of template comes in the
"HtmlValue" field of the template and can be replaced.
We will use "mail.setHTMLBody(htmlvalue)"
3. If we are using "mail.setTemplateid" then we have to give
"setTargetObjectId". But reverse is not necessary.
4. TargetObjectId can only be the Id of Contacts, Leads & Users.
5. "setTemplateId" replaces "setSubject" & "setHTMLBody/setPlainTextBody".
"setTargetObjectId" replaces "settoAddresses".
----------------------------------
OPPORTUNITY & PRODUCT RELATIONSHIP
----------------------------------
1. Opp Line Item comes under Opportunity & PriceBookEntry.
2. Opp Line Item has look up to PriceBookEntry & PriceBookEntry has look upto
Product2 & PriceBook2.
---------------------------
TASK & PROFILE RELATIONSHIP
---------------------------
1. Task has look up to User.
2. User has look up to Profile.
3. For getting current Logged in User Information we use - UserInfo.getUserId();
4. For getting current logged in user profile information we use -
UserInfo.getProfileId();
--------------------------
PREVENT RECURSIVE TRIGGERS
--------------------------
1. Create a class with below code:
public class preventRepeat
{
public static boolean isRepeat=false;
}
2. In the Trigger implement this code:
if(!preventRepeat.isRepeat)
{
preventRepeat.isRepeat = true ;
//Trigger Body;
}
------------
MAP CONCEPTS
------------
1. Always use map when we have relationships: Lookup or Master-Detail.
2. When putting value in Map, Start For loop with Child/Detail object. In below
example: Master is ACCOUNT and Detail is OPPOTUNITY
for(Opportunity opp : lstopp)
{
if(map1.get(opp.accountId)==null)
{
map1.put(opp.accountId,new list<opportunity>());
}
map1.get(opp.accountId).add(opp);
}
3. Get Value from For Loop on Master object.
for(Account acc1 : trigger.new)
{
List<Opportunity> lstOpp1 = map1.get(acc1.Id);
for(Opportunity opp1 : lstOpp1)
{
if(opp1.CreatedDate > d)
{
Opp1.StageName = 'closed lost';
}
else
{
Opp1.StageName = 'closed Won';
}
lsttoupdate.add(opp1);
}
}
------------------
AGGREGATE FUNCTION
------------------
1. When we use AggregateResult we have to use "GROUP BY" clause.
for (AggregateResult results : [Select Account.id acc,Sum(Amount)amount
From Opportunity where accountId in:trigger.newmap.keyset() GROUP BY
Account.id])
{
system.debug(results );
ammountmap.put((ID)results.get('acc'),
(double)results.get('amount'));
}
2. Getting values from AggregateResult: (ID)results.get('acc') where ID is "Data
Type" and acc is "Alias"
------------------------
SEND ATTACHMENT IN EMAIL
------------------------
1. To create Attachment:
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName('email_pdf');
efa.setBody(b); //where b is "Blob"
2. To attach the attachment:
mail.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
-------------
SHARING RULES (STANDARD OBJECT)
-------------
1. Create instance for the sharing object. For example:
For Account --> Sharing object is "AccountShare"
1. AccountShare accshr = new AccountShare();
2. accshr.Accountid = acc.id; //where acc is any Account
Set the user or group id: accshr.UserOrGroupId = user1.id;
3. accshr.AccountAccessLevel= 'edit'; //Defining Account
accesslevel. It Can "Read" "Edit" "All"
4. accshr.OpportunityAccessLevel= 'edit'; //Defining child object
accesslevel. It Can "Read" "Edit" "None"
5. accshr.RowCause = Schema.AccountShare.RowCause.Manual;
/* Reason that this sharing entry exists. Read-only. There are many
possible values, including:
Manual Sharing—The User or Group has access because a User with
—All— access manually shared the Account with them.
Owner—The User is the owner of the Account or is in a Role above the
Account owner in the role hierarchy.
Sales Team—The User or Group has team access (is an
AccountTeamMember).
Sharing Rule—The User or Group has access via an Account sharing
rule. */
6. ATlast insert the sharing object i.e. insert "accshr";
-------------
SHARING RULES (CUSTOM OBJECT)
-------------
1. Instantiate the sharing object: Student__Share stuShr= new Student__Share
();
2. Set Parent ID: stuShr.ParentId = stu .Id;
3. Set the user or group id: stuShr.UserOrGroupId = user1.id;
4. Set access Level: stuShr.AccessLevel = 'edit';
5. Set Row Cause: stuShr.RowCause =
Schema.Student__Share.RowCause.Manual;
6. Insert object: insert stuShr;
-----------
BATCH CLASS
-----------
1. "Database.Batchable" interface is implemented.
global class class_name implements Database.Batchable<sObject> //Global
is access modifier & class_name is the name of Batch Class
2. There are three methods that are implemented in the batch class:
- START METHOD: global (Database.QueryLocator | Iterable<sObject>)
start(Database.BatchableContext bc)
{
//In this method data is queried from the database
on which operation is to be performed.
//Database.QueryLocator or Iterable<sObject> is
the return type of this method.
//QueryLocator bypasses the governor limit on the
number of records returned by SOQL.
}
- EXECUTE METHOD: global void execute(Database.BatchableContext BC,
list<sObject>)
{
//This method includes the operation that is being
performed through this batch class.
//Second arguement in this method is the List
which contains the records of the sObject or any other primitive data type.
}
- FINISH METHOD: global void finish(Database.BatchableContext BC)
{
//In this method we can perform any task such as
Sending a notification email that the job has been completed.
}
3. If we have to make any CALLOUT in our batch class then an additional
interface is also implemented:
global class class_name implements Database.Batchable<sObject>,
Database.AllowCallouts
4. Batch jobs are executed in a batch of 200. So any summary field is
recalculated in a new batch.
So if we want to keep track of any field or in other words we want to
maintain the state then an additional interface is implemented:
global class_name implements Database.Batchable<sObject>,
Database.Stateful
-----------------------------------------
EXAMPLE OF BATCH CLASS USING QUERYLOCATOR
-----------------------------------------
global class batch_Class implements Database.Batchable<sObject>
{
Global string query;
global batch_Class()
{
query = 'Select id,email from Student where Balance>0';
}
global Database.QueryLocator start(Database.BatchableContext bc)
{
Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc, List<Student> stuList)
{
For(Student stu:stuList)
{
//Send Email Code
}
}
global void Finish(Database.BatchableContext bc)
{
}
}
---------------
SCHEDULER CLASS
---------------
1. "Schedulable" interface is implemented.
2. There is one method in this interface that is implemented in our scheduler
class.
- EXECUTE: global void execute(SchedulableContext sc){}
3. global class Scheduler_Class_Name implements Schedulable
{
global void execute(SchedulableContext SC)
{
Class_tobeScheduled obj = new Class_tobeScheduled();
}
}
4. Now "System.Schedule" method is called from the developer console with
following parameters:
Scheduler_Class_Name sch = new Scheduler_Class_Namee();
//Scheduler class is instantiated.
String str = '20 30 8 10 2 ?'; //('Seconds
Minutes Hours Day_of_Month Month Day_of_week Optional_Year')
system.schedule('Merge Job', str, sch); //('Scheduled
Job Name, Scheduled Period, Instance of Scheduler class')
5. Example: (* * 20 ? * ?) // It means that our class will run every
month at 20:00 hours
(* * 20 * * 2012) // It means that our class will run every day at
20:00 hours of 2012 year.
-----
NOTE:
-----
1. Never user DML operation in Trigger.new
2. Query the new records using any collection and then apply any DML on that
list.
{
}
}
---------------
SCHEDULER CLASS
---------------
1. "Schedulable" interface is implemented.
2. There is one method in this interface that is implemented in our scheduler
class.
- EXECUTE: global void execute(SchedulableContext sc){}
3. global class Scheduler_Class_Name implements Schedulable
{
global void execute(SchedulableContext SC)
{
Class_tobeScheduled obj = new Class_tobeScheduled();
}
}
4. Now "System.Schedule" method is called from the developer console with
following parameters:
Scheduler_Class_Name sch = new Scheduler_Class_Namee();
//Scheduler class is instantiated.
String str = '20 30 8 10 2 ?'; //('Seconds
Minutes Hours Day_of_Month Month Day_of_week Optional_Year')
system.schedule('Merge Job', str, sch); //('Scheduled
Job Name, Scheduled Period, Instance of Scheduler class')
5. Example: (* * 20 ? * ?) // It means that our class will run every
month at 20:00 hours
(* * 20 * * 2012) // It means that our class will run every day at
20:00 hours of 2012 year.
-----
NOTE:
-----
1. Never user DML operation in Trigger.new
2. Query the new records using any collection and then apply any DML on that
list.

More Related Content

What's hot

The Tools for Data Migration Between Oracle , MySQL and Flat Text File.
The Tools for Data Migration Between Oracle , MySQL and Flat Text File.The Tools for Data Migration Between Oracle , MySQL and Flat Text File.
The Tools for Data Migration Between Oracle , MySQL and Flat Text File.anysql
 
Exercises of java tutoring -version1
Exercises of java tutoring -version1Exercises of java tutoring -version1
Exercises of java tutoring -version1Uday Sharma
 
Developing for Node.JS with MySQL and NoSQL
Developing for Node.JS with MySQL and NoSQLDeveloping for Node.JS with MySQL and NoSQL
Developing for Node.JS with MySQL and NoSQLJohn David Duncan
 
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
Whitepaper To Study Filestream Option In Sql Server
Whitepaper To Study Filestream Option In Sql ServerWhitepaper To Study Filestream Option In Sql Server
Whitepaper To Study Filestream Option In Sql ServerShahzad
 
Conexcion java mysql
Conexcion java mysqlConexcion java mysql
Conexcion java mysqljbersosa
 
Building node.js applications with Database Jones
Building node.js applications with Database JonesBuilding node.js applications with Database Jones
Building node.js applications with Database JonesJohn David Duncan
 
4Developers: Dominik Przybysz- Message Brokers
4Developers: Dominik Przybysz- Message Brokers4Developers: Dominik Przybysz- Message Brokers
4Developers: Dominik Przybysz- Message BrokersPROIDEA
 
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup itPROIDEA
 
How to become an Android dev starting from iOS (and vice versa)
How to become an Android dev starting from iOS (and vice versa)How to become an Android dev starting from iOS (and vice versa)
How to become an Android dev starting from iOS (and vice versa)Giuseppe Filograno
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursorsinfo_zybotech
 
Synapse india reviews on php and sql
Synapse india reviews on php and sqlSynapse india reviews on php and sql
Synapse india reviews on php and sqlsaritasingh19866
 

What's hot (19)

The Tools for Data Migration Between Oracle , MySQL and Flat Text File.
The Tools for Data Migration Between Oracle , MySQL and Flat Text File.The Tools for Data Migration Between Oracle , MySQL and Flat Text File.
The Tools for Data Migration Between Oracle , MySQL and Flat Text File.
 
Exercises of java tutoring -version1
Exercises of java tutoring -version1Exercises of java tutoring -version1
Exercises of java tutoring -version1
 
Developing for Node.JS with MySQL and NoSQL
Developing for Node.JS with MySQL and NoSQLDeveloping for Node.JS with MySQL and NoSQL
Developing for Node.JS with MySQL and NoSQL
 
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
 
Oracle training in hyderabad
Oracle training in hyderabadOracle training in hyderabad
Oracle training in hyderabad
 
Lecture17
Lecture17Lecture17
Lecture17
 
MySQL
MySQLMySQL
MySQL
 
Whitepaper To Study Filestream Option In Sql Server
Whitepaper To Study Filestream Option In Sql ServerWhitepaper To Study Filestream Option In Sql Server
Whitepaper To Study Filestream Option In Sql Server
 
Codemotion appengine
Codemotion appengineCodemotion appengine
Codemotion appengine
 
Conexcion java mysql
Conexcion java mysqlConexcion java mysql
Conexcion java mysql
 
Building node.js applications with Database Jones
Building node.js applications with Database JonesBuilding node.js applications with Database Jones
Building node.js applications with Database Jones
 
4Developers: Dominik Przybysz- Message Brokers
4Developers: Dominik Przybysz- Message Brokers4Developers: Dominik Przybysz- Message Brokers
4Developers: Dominik Przybysz- Message Brokers
 
Introduction to php database connectivity
Introduction to php  database connectivityIntroduction to php  database connectivity
Introduction to php database connectivity
 
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
4Developers: Michał Szczepanik- Kotlin - Let’s ketchup it
 
How to become an Android dev starting from iOS (and vice versa)
How to become an Android dev starting from iOS (and vice versa)How to become an Android dev starting from iOS (and vice versa)
How to become an Android dev starting from iOS (and vice versa)
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursors
 
Les14
Les14Les14
Les14
 
Java beans
Java beansJava beans
Java beans
 
Synapse india reviews on php and sql
Synapse india reviews on php and sqlSynapse india reviews on php and sql
Synapse india reviews on php and sql
 

Similar to Salesforce, APEX Concepts

WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEWINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEHitesh Mohapatra
 
Stored procedure Notes By Durgesh Singh
Stored procedure Notes By Durgesh SinghStored procedure Notes By Durgesh Singh
Stored procedure Notes By Durgesh Singhimdurgesh
 
QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7Akash Tyagi
 
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdfUsing c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdffashiongallery1
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfaromanets
 
Csphtp1 08
Csphtp1 08Csphtp1 08
Csphtp1 08HUST
 
Part APurposeThis laboratory provides some experience work.docx
Part APurposeThis laboratory provides some experience work.docxPart APurposeThis laboratory provides some experience work.docx
Part APurposeThis laboratory provides some experience work.docxdewhirstichabod
 
Ive posted 3 classes after the instruction that were given at star.pdf
Ive posted 3 classes after the instruction that were given at star.pdfIve posted 3 classes after the instruction that were given at star.pdf
Ive posted 3 classes after the instruction that were given at star.pdfdeepaarora22
 
Java căn bản - Chapter4
Java căn bản - Chapter4Java căn bản - Chapter4
Java căn bản - Chapter4Vince Vo
 
Chapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part IChapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part IEduardo Bergavera
 
Plsql task
Plsql taskPlsql task
Plsql taskNawaz Sk
 
Introduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinIntroduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinSimon Gauvin
 
For this lab, you will write the following filesAbstractDataCalc.pdf
For this lab, you will write the following filesAbstractDataCalc.pdfFor this lab, you will write the following filesAbstractDataCalc.pdf
For this lab, you will write the following filesAbstractDataCalc.pdfalokindustries1
 

Similar to Salesforce, APEX Concepts (20)

Sql server-function
Sql server-functionSql server-function
Sql server-function
 
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEWINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
 
Databases with SQLite3.pdf
Databases with SQLite3.pdfDatabases with SQLite3.pdf
Databases with SQLite3.pdf
 
Stored procedure Notes By Durgesh Singh
Stored procedure Notes By Durgesh SinghStored procedure Notes By Durgesh Singh
Stored procedure Notes By Durgesh Singh
 
QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7
 
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdfUsing c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
 
Csphtp1 08
Csphtp1 08Csphtp1 08
Csphtp1 08
 
Part APurposeThis laboratory provides some experience work.docx
Part APurposeThis laboratory provides some experience work.docxPart APurposeThis laboratory provides some experience work.docx
Part APurposeThis laboratory provides some experience work.docx
 
Ive posted 3 classes after the instruction that were given at star.pdf
Ive posted 3 classes after the instruction that were given at star.pdfIve posted 3 classes after the instruction that were given at star.pdf
Ive posted 3 classes after the instruction that were given at star.pdf
 
Java căn bản - Chapter4
Java căn bản - Chapter4Java căn bản - Chapter4
Java căn bản - Chapter4
 
Chapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part IChapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part I
 
Pl sql using_xml
Pl sql using_xmlPl sql using_xml
Pl sql using_xml
 
Create Components in TomatoCMS
Create Components in TomatoCMSCreate Components in TomatoCMS
Create Components in TomatoCMS
 
Mvc acchitecture
Mvc acchitectureMvc acchitecture
Mvc acchitecture
 
Plsql task
Plsql taskPlsql task
Plsql task
 
Online CPP Homework Help
Online CPP Homework HelpOnline CPP Homework Help
Online CPP Homework Help
 
Introduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinIntroduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon Gauvin
 
Msql
Msql Msql
Msql
 
For this lab, you will write the following filesAbstractDataCalc.pdf
For this lab, you will write the following filesAbstractDataCalc.pdfFor this lab, you will write the following filesAbstractDataCalc.pdf
For this lab, you will write the following filesAbstractDataCalc.pdf
 

Recently uploaded

AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 

Recently uploaded (20)

AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 

Salesforce, APEX Concepts

  • 1. -------------- EMAIL TEMPLATE -------------- 1. When we are using Text Email Template then the body of template comes in the "body" field of the template and can be replaced. We will use "mail.setPlainTextBody(body)" 2. When we are using HTML Email Template then the body of template comes in the "HtmlValue" field of the template and can be replaced. We will use "mail.setHTMLBody(htmlvalue)" 3. If we are using "mail.setTemplateid" then we have to give "setTargetObjectId". But reverse is not necessary. 4. TargetObjectId can only be the Id of Contacts, Leads & Users. 5. "setTemplateId" replaces "setSubject" & "setHTMLBody/setPlainTextBody". "setTargetObjectId" replaces "settoAddresses". ---------------------------------- OPPORTUNITY & PRODUCT RELATIONSHIP ---------------------------------- 1. Opp Line Item comes under Opportunity & PriceBookEntry. 2. Opp Line Item has look up to PriceBookEntry & PriceBookEntry has look upto Product2 & PriceBook2. --------------------------- TASK & PROFILE RELATIONSHIP --------------------------- 1. Task has look up to User. 2. User has look up to Profile. 3. For getting current Logged in User Information we use - UserInfo.getUserId(); 4. For getting current logged in user profile information we use - UserInfo.getProfileId(); -------------------------- PREVENT RECURSIVE TRIGGERS -------------------------- 1. Create a class with below code: public class preventRepeat { public static boolean isRepeat=false; } 2. In the Trigger implement this code: if(!preventRepeat.isRepeat) { preventRepeat.isRepeat = true ; //Trigger Body; } ------------
  • 2. MAP CONCEPTS ------------ 1. Always use map when we have relationships: Lookup or Master-Detail. 2. When putting value in Map, Start For loop with Child/Detail object. In below example: Master is ACCOUNT and Detail is OPPOTUNITY for(Opportunity opp : lstopp) { if(map1.get(opp.accountId)==null) { map1.put(opp.accountId,new list<opportunity>()); } map1.get(opp.accountId).add(opp); } 3. Get Value from For Loop on Master object. for(Account acc1 : trigger.new) { List<Opportunity> lstOpp1 = map1.get(acc1.Id); for(Opportunity opp1 : lstOpp1) { if(opp1.CreatedDate > d) { Opp1.StageName = 'closed lost'; } else { Opp1.StageName = 'closed Won'; } lsttoupdate.add(opp1); } } ------------------ AGGREGATE FUNCTION ------------------ 1. When we use AggregateResult we have to use "GROUP BY" clause. for (AggregateResult results : [Select Account.id acc,Sum(Amount)amount From Opportunity where accountId in:trigger.newmap.keyset() GROUP BY Account.id]) { system.debug(results ); ammountmap.put((ID)results.get('acc'), (double)results.get('amount')); } 2. Getting values from AggregateResult: (ID)results.get('acc') where ID is "Data Type" and acc is "Alias" ------------------------ SEND ATTACHMENT IN EMAIL ------------------------ 1. To create Attachment: Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
  • 3. efa.setFileName('email_pdf'); efa.setBody(b); //where b is "Blob" 2. To attach the attachment: mail.setFileAttachments(new Messaging.EmailFileAttachment[] {efa}); ------------- SHARING RULES (STANDARD OBJECT) ------------- 1. Create instance for the sharing object. For example: For Account --> Sharing object is "AccountShare" 1. AccountShare accshr = new AccountShare(); 2. accshr.Accountid = acc.id; //where acc is any Account Set the user or group id: accshr.UserOrGroupId = user1.id; 3. accshr.AccountAccessLevel= 'edit'; //Defining Account accesslevel. It Can "Read" "Edit" "All" 4. accshr.OpportunityAccessLevel= 'edit'; //Defining child object accesslevel. It Can "Read" "Edit" "None" 5. accshr.RowCause = Schema.AccountShare.RowCause.Manual; /* Reason that this sharing entry exists. Read-only. There are many possible values, including: Manual Sharing—The User or Group has access because a User with —All— access manually shared the Account with them. Owner—The User is the owner of the Account or is in a Role above the Account owner in the role hierarchy. Sales Team—The User or Group has team access (is an AccountTeamMember). Sharing Rule—The User or Group has access via an Account sharing rule. */ 6. ATlast insert the sharing object i.e. insert "accshr"; ------------- SHARING RULES (CUSTOM OBJECT) ------------- 1. Instantiate the sharing object: Student__Share stuShr= new Student__Share (); 2. Set Parent ID: stuShr.ParentId = stu .Id; 3. Set the user or group id: stuShr.UserOrGroupId = user1.id; 4. Set access Level: stuShr.AccessLevel = 'edit'; 5. Set Row Cause: stuShr.RowCause = Schema.Student__Share.RowCause.Manual; 6. Insert object: insert stuShr; ----------- BATCH CLASS ----------- 1. "Database.Batchable" interface is implemented. global class class_name implements Database.Batchable<sObject> //Global is access modifier & class_name is the name of Batch Class 2. There are three methods that are implemented in the batch class: - START METHOD: global (Database.QueryLocator | Iterable<sObject>) start(Database.BatchableContext bc)
  • 4. { //In this method data is queried from the database on which operation is to be performed. //Database.QueryLocator or Iterable<sObject> is the return type of this method. //QueryLocator bypasses the governor limit on the number of records returned by SOQL. } - EXECUTE METHOD: global void execute(Database.BatchableContext BC, list<sObject>) { //This method includes the operation that is being performed through this batch class. //Second arguement in this method is the List which contains the records of the sObject or any other primitive data type. } - FINISH METHOD: global void finish(Database.BatchableContext BC) { //In this method we can perform any task such as Sending a notification email that the job has been completed. } 3. If we have to make any CALLOUT in our batch class then an additional interface is also implemented: global class class_name implements Database.Batchable<sObject>, Database.AllowCallouts 4. Batch jobs are executed in a batch of 200. So any summary field is recalculated in a new batch. So if we want to keep track of any field or in other words we want to maintain the state then an additional interface is implemented: global class_name implements Database.Batchable<sObject>, Database.Stateful ----------------------------------------- EXAMPLE OF BATCH CLASS USING QUERYLOCATOR ----------------------------------------- global class batch_Class implements Database.Batchable<sObject> { Global string query; global batch_Class() { query = 'Select id,email from Student where Balance>0'; } global Database.QueryLocator start(Database.BatchableContext bc) { Database.getQueryLocator(query); } global void execute(Database.BatchableContext bc, List<Student> stuList) { For(Student stu:stuList) { //Send Email Code } } global void Finish(Database.BatchableContext bc)
  • 5. { } } --------------- SCHEDULER CLASS --------------- 1. "Schedulable" interface is implemented. 2. There is one method in this interface that is implemented in our scheduler class. - EXECUTE: global void execute(SchedulableContext sc){} 3. global class Scheduler_Class_Name implements Schedulable { global void execute(SchedulableContext SC) { Class_tobeScheduled obj = new Class_tobeScheduled(); } } 4. Now "System.Schedule" method is called from the developer console with following parameters: Scheduler_Class_Name sch = new Scheduler_Class_Namee(); //Scheduler class is instantiated. String str = '20 30 8 10 2 ?'; //('Seconds Minutes Hours Day_of_Month Month Day_of_week Optional_Year') system.schedule('Merge Job', str, sch); //('Scheduled Job Name, Scheduled Period, Instance of Scheduler class') 5. Example: (* * 20 ? * ?) // It means that our class will run every month at 20:00 hours (* * 20 * * 2012) // It means that our class will run every day at 20:00 hours of 2012 year. ----- NOTE: ----- 1. Never user DML operation in Trigger.new 2. Query the new records using any collection and then apply any DML on that list.
  • 6. { } } --------------- SCHEDULER CLASS --------------- 1. "Schedulable" interface is implemented. 2. There is one method in this interface that is implemented in our scheduler class. - EXECUTE: global void execute(SchedulableContext sc){} 3. global class Scheduler_Class_Name implements Schedulable { global void execute(SchedulableContext SC) { Class_tobeScheduled obj = new Class_tobeScheduled(); } } 4. Now "System.Schedule" method is called from the developer console with following parameters: Scheduler_Class_Name sch = new Scheduler_Class_Namee(); //Scheduler class is instantiated. String str = '20 30 8 10 2 ?'; //('Seconds Minutes Hours Day_of_Month Month Day_of_week Optional_Year') system.schedule('Merge Job', str, sch); //('Scheduled Job Name, Scheduled Period, Instance of Scheduler class') 5. Example: (* * 20 ? * ?) // It means that our class will run every month at 20:00 hours (* * 20 * * 2012) // It means that our class will run every day at 20:00 hours of 2012 year. ----- NOTE: ----- 1. Never user DML operation in Trigger.new 2. Query the new records using any collection and then apply any DML on that list.