SlideShare a Scribd company logo
1 of 38
Download to read offline
Fatima Arrou
Salesforce Consultant & Developer
@ BOUYGUES IMMOBILIER
Mirela Smajovic
Salesforce Consultant
@UP Crm
Sit Amet @ Consectetur
Survey Result
Agenda
1. What’s an Apex Trigger ?
2. When to use Apex Trigger?
3. What are types of Trigger?
4. Basic Syntax of Trigger
5. Difference between Trigger.New and Trigger.Old
6. Trigger example
7. Summer ’20 : New Flows Features
8. Quiz
Apex : langage de programmation utilisé sur la plateforme Salesforce.
Script : portion de code permettant d’effectuer un traitement spécifique.
Method : script identifié par un nom, inclus dans une classe, exécutable depuis
n’importe où dans d’autres scripts.
SOQL (Salesforce Object Query Language) : langage permettant d’accéder aux
enregistrements dans les objets.
Query : instruction écrite dans le langage SOQL (sélection d’enregistrements)
Before we begin, a bit of vocabulary
What’s an Apex Trigger?
What’s an Apex Trigger?
A trigger is an Apex script that executes before or after data
manipulation language (DML) events occur. Apex triggers enable you to
perform custom actions before or after events to record in Salesforce,
such as insertions, updates, or deletions.
DML (Data Manipulation Language) : opération permettant de faire des…
Insert/Update : insérer / mettre à jour
Upsert : mettre à jour les enregistrements s’ils existent, et ajouter les nouveaux,
dans une même opération
Delete/Undelete : supprimer un enregistrement / annuler la suppression
Merge : fusionner deux enregistrements
What is a DML?
When to use Apex Trigger
The benefit of using Apex Trigger
● Perform operations according to specific conditions
● Prevent certain operations from being executed
● Modify associated records
● Execute all possible actions in Apex, including executing SOQL
and DML queries
● Call custom Apex methods.
•It is a piece of code which is executed either before or after a
record is updated or inserted.
•150 DML operations can be used in a single trigger.
•50 000 is maximum number of records retrieved by SOQL
queries
•You can access triggers across an object and related to that
object.
Salesforce Trigger
Salesforce Trigger vs. Workflows
•Workflows cannot create or update a separate object.
•You can’t reference certain fields when using
workflows.
•You will not have your workflow doing more than just
field updates and emails.
Salesforce Trigger vs. Process Builder
•Process Builders cannot handle before DML It executes
after a record has been created or updated. Whereas Apex
triggers can handle both before and after DML operations.
•Process Builder cannot handle delete and undelete DML.
Whereas Apex triggers can handle all DML operations.
Types Of triggers
Types Of triggers
Before Trigger After Trigger
is used to either update or
validate the values of a
record before they can be
saved into the database.
is used to access the field
values set by the system
and affect any change in
the record.
Order of execution
Basic Syntax of Trigger
Basic Syntax of Trigger
trigger_events can be a comma-separated list
of one or more of the following events:
● Before insert
● Before update
● Before delete
● After insert
● After update
● After delete
● After undelete
Basic Syntax of Trigger
Using Context variables
Context variables
What’s context variable ?
→ provide access to the records that caused the trigger fired
Trigger.new Trigger.old
Contains all the records
that were inserted in insert
or update triggers
Provides the old version of
sObjects before they were
updated in update triggers, or
a list of deleted sObjects in
delete triggers
Context variables
Triggers fired when one
record or many records
are inserted/updated
Context variable
can contain one or
many records
You can iterate
over Trigger.New
to get each
individual sObject
Ex 1: Insert one account → Trigger.new contain one record → Iteration on one record
Ex 2: Insert 10 accounts → Trigger.new contain 10 records → Iteration on 10 records
X10
How to write a trigger ?
Ex from developer console
How to write a trigger ?
How to write a trigger ?
How to write a trigger ?
With a real example ?
Need to deactivate opportunities related to an
inactive account
We want that when the Account active field changes to “No”, we deactivate
all related opportunities
Account
Active : Yes ⇒ No
Opportunity 1
Active : Yes ⇒ No
Opportunity 2
Active : Yes ⇒ No
GO DEMO :)
Update on Account
(field Active__c : Yes → No)
Iteration on updated record
Active field of updated
record = ‘No’ ?
If ok → Add account Id in a
list
Get Account Id
Get related opp
Get all related opportunities
in a list
Update active field on Opp
Iteration on all related Opp
Change value of active field
on Opp
Add updated Opp to a list
Update the list
In Summer ’20 : New Flows Features
In Summer ’20 there is a couple of major updates; firstly you can now trigger a flow after a record is
saved, in the same way a Before Trigger works in Apex.
You also have an easy way to kick off a Flow, with the new and improved Start Element.
Flow is receiving a huge amount of attention
from Salesforce, creating a declarative tool
that allows Admins to build Apex like
functions.
Trailhead Learning
Summer ‘20 release notes :
https://releasenotes.docs.salesforce.com/en-us/summer20/release-notes/rn_forcecom_flow_fbuilder_after-save_trigger.htm
Apex Triggers : https://trailhead.salesforce.com/en/content/learn/modules/apex_triggers
Apex Basics & Database : https://trailhead.salesforce.com/en/content/learn/modules/apex_database
Quick Start: Apex Coding for Admins :
https://trailhead.salesforce.com/en/content/learn/projects/quick-start-apex-coding-for-admins
Upcoming Meeting
Thu, Jun 11, 6:00 PM (CEST)
Intégration Continue et Couverture de Test Avec
GitHub Actions et Codecov.io
Paris, FR Developers Group
https://trailblazercommunitygroups.com/events/details/salesforce-paris-fr-developers-group-presents-integration-continue-et-
couverture-de-test-avec-github-actions-et-codecovio/#/
Sources
https://intellipaat.com/blog/tutorial/salesforce-tutorial/triggers-in-salesforce/

More Related Content

Similar to Ecrire son premier Trigger (et les comprendre)

Apex code-fundamentals
Apex code-fundamentalsApex code-fundamentals
Apex code-fundamentalsAmit Sharma
 
Processing large volume of data with MuleSoft and salesforce.pptx
Processing large volume of data with MuleSoft and salesforce.pptxProcessing large volume of data with MuleSoft and salesforce.pptx
Processing large volume of data with MuleSoft and salesforce.pptxPankaj Goyal
 
Processing large volume of data with MuleSoft and salesforce.pptx
Processing large volume of data with MuleSoft and salesforce.pptxProcessing large volume of data with MuleSoft and salesforce.pptx
Processing large volume of data with MuleSoft and salesforce.pptxPankajGoyal164048
 
Apex code-fundamentals
Apex code-fundamentalsApex code-fundamentals
Apex code-fundamentalsAmit Sharma
 
Episode 12 - Basics of Trigger
Episode 12 - Basics of TriggerEpisode 12 - Basics of Trigger
Episode 12 - Basics of TriggerJitendra Zaa
 
Salesforce Basic Development
Salesforce Basic DevelopmentSalesforce Basic Development
Salesforce Basic DevelopmentNaveen Dhanaraj
 
Alternate for scheduled apex using flow builder
Alternate for scheduled apex using flow builderAlternate for scheduled apex using flow builder
Alternate for scheduled apex using flow builderKadharBashaJ
 
Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...
Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...
Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...Anna Loughnan Colquhoun
 
Programming Building Blocks for Admins
Programming Building Blocks for Admins Programming Building Blocks for Admins
Programming Building Blocks for Admins Salesforce Admins
 
Mastering solr
Mastering solrMastering solr
Mastering solrjurcello
 
Process builder vs Triggers
Process builder vs TriggersProcess builder vs Triggers
Process builder vs TriggersProQuest
 
Hands-On Workshop: Introduction to Development on Force.com for Developers
Hands-On Workshop: Introduction to Development on Force.com for DevelopersHands-On Workshop: Introduction to Development on Force.com for Developers
Hands-On Workshop: Introduction to Development on Force.com for DevelopersSalesforce Developers
 
Apex Trigger in Salesforce
Apex Trigger in SalesforceApex Trigger in Salesforce
Apex Trigger in SalesforceCloud Analogy
 
Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsSalesforce Developers
 
Salesforce Summer 14 Release
Salesforce Summer 14 ReleaseSalesforce Summer 14 Release
Salesforce Summer 14 ReleaseJyothylakshmy P.U
 
Salesforce Admin Group-Barcelona-2022-07-05 In-person Meetup-BCN Admins Group
Salesforce Admin Group-Barcelona-2022-07-05 In-person Meetup-BCN Admins GroupSalesforce Admin Group-Barcelona-2022-07-05 In-person Meetup-BCN Admins Group
Salesforce Admin Group-Barcelona-2022-07-05 In-person Meetup-BCN Admins Groupanimuscrm
 
Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...
Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...
Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...Salesforce Developers
 
Denver Salesforce DUG DF 2018 roundup
Denver Salesforce DUG DF 2018 roundup Denver Salesforce DUG DF 2018 roundup
Denver Salesforce DUG DF 2018 roundup Mike Tetlow
 
10 Creating Triggers
10 Creating Triggers10 Creating Triggers
10 Creating Triggersrehaniltifat
 

Similar to Ecrire son premier Trigger (et les comprendre) (20)

Apex code-fundamentals
Apex code-fundamentalsApex code-fundamentals
Apex code-fundamentals
 
Processing large volume of data with MuleSoft and salesforce.pptx
Processing large volume of data with MuleSoft and salesforce.pptxProcessing large volume of data with MuleSoft and salesforce.pptx
Processing large volume of data with MuleSoft and salesforce.pptx
 
Processing large volume of data with MuleSoft and salesforce.pptx
Processing large volume of data with MuleSoft and salesforce.pptxProcessing large volume of data with MuleSoft and salesforce.pptx
Processing large volume of data with MuleSoft and salesforce.pptx
 
Apex code-fundamentals
Apex code-fundamentalsApex code-fundamentals
Apex code-fundamentals
 
Episode 12 - Basics of Trigger
Episode 12 - Basics of TriggerEpisode 12 - Basics of Trigger
Episode 12 - Basics of Trigger
 
Salesforce Basic Development
Salesforce Basic DevelopmentSalesforce Basic Development
Salesforce Basic Development
 
Alternate for scheduled apex using flow builder
Alternate for scheduled apex using flow builderAlternate for scheduled apex using flow builder
Alternate for scheduled apex using flow builder
 
Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...
Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...
Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...
 
Programming Building Blocks for Admins
Programming Building Blocks for Admins Programming Building Blocks for Admins
Programming Building Blocks for Admins
 
Mastering solr
Mastering solrMastering solr
Mastering solr
 
Process builder vs Triggers
Process builder vs TriggersProcess builder vs Triggers
Process builder vs Triggers
 
Hands-On Workshop: Introduction to Development on Force.com for Developers
Hands-On Workshop: Introduction to Development on Force.com for DevelopersHands-On Workshop: Introduction to Development on Force.com for Developers
Hands-On Workshop: Introduction to Development on Force.com for Developers
 
Apex Trigger in Salesforce
Apex Trigger in SalesforceApex Trigger in Salesforce
Apex Trigger in Salesforce
 
Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong Foundations
 
Salesforce Summer 14 Release
Salesforce Summer 14 ReleaseSalesforce Summer 14 Release
Salesforce Summer 14 Release
 
Salesforce Admin Group-Barcelona-2022-07-05 In-person Meetup-BCN Admins Group
Salesforce Admin Group-Barcelona-2022-07-05 In-person Meetup-BCN Admins GroupSalesforce Admin Group-Barcelona-2022-07-05 In-person Meetup-BCN Admins Group
Salesforce Admin Group-Barcelona-2022-07-05 In-person Meetup-BCN Admins Group
 
Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...
Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...
Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...
 
Salesforce
SalesforceSalesforce
Salesforce
 
Denver Salesforce DUG DF 2018 roundup
Denver Salesforce DUG DF 2018 roundup Denver Salesforce DUG DF 2018 roundup
Denver Salesforce DUG DF 2018 roundup
 
10 Creating Triggers
10 Creating Triggers10 Creating Triggers
10 Creating Triggers
 

More from Doria Hamelryk

Salesforce Release Spring 24 - French Gathering
Salesforce Release Spring 24 - French GatheringSalesforce Release Spring 24 - French Gathering
Salesforce Release Spring 24 - French GatheringDoria Hamelryk
 
Apex for Admins Workshop
Apex for Admins WorkshopApex for Admins Workshop
Apex for Admins WorkshopDoria Hamelryk
 
Concours Trailblazers be Certified
Concours Trailblazers be Certified Concours Trailblazers be Certified
Concours Trailblazers be Certified Doria Hamelryk
 
+10 of Our Favorite Salesforce Spring ’21 Features
+10 of Our Favorite Salesforce Spring ’21 Features+10 of Our Favorite Salesforce Spring ’21 Features
+10 of Our Favorite Salesforce Spring ’21 FeaturesDoria Hamelryk
 
Découverte d'Einstein Analytics (Tableau CRM)
Découverte d'Einstein Analytics (Tableau CRM)Découverte d'Einstein Analytics (Tableau CRM)
Découverte d'Einstein Analytics (Tableau CRM)Doria Hamelryk
 
Odaseva : un outil de gestion pour les règles RGPD
Odaseva : un outil de gestion pour les règles RGPDOdaseva : un outil de gestion pour les règles RGPD
Odaseva : un outil de gestion pour les règles RGPDDoria Hamelryk
 
Opportunity Management workshop
Opportunity Management workshopOpportunity Management workshop
Opportunity Management workshopDoria Hamelryk
 
A la découverte de pardot
A la découverte de pardotA la découverte de pardot
A la découverte de pardotDoria Hamelryk
 
Flows - what you should know before implementing
Flows - what you should know before implementingFlows - what you should know before implementing
Flows - what you should know before implementingDoria Hamelryk
 
Gérer ses campagnes marketing
Gérer ses campagnes marketingGérer ses campagnes marketing
Gérer ses campagnes marketingDoria Hamelryk
 
10 of Our Favorite Salesforce Winter ’21 Features
10 of Our Favorite Salesforce Winter ’21 Features10 of Our Favorite Salesforce Winter ’21 Features
10 of Our Favorite Salesforce Winter ’21 FeaturesDoria Hamelryk
 
Les formules et moi, ça fait 3!
Les formules et moi, ça fait 3!Les formules et moi, ça fait 3!
Les formules et moi, ça fait 3!Doria Hamelryk
 
Salesforce Import Tools
Salesforce Import ToolsSalesforce Import Tools
Salesforce Import ToolsDoria Hamelryk
 
Concours Ladies be Certified #sfpariswit
Concours Ladies be Certified #sfpariswitConcours Ladies be Certified #sfpariswit
Concours Ladies be Certified #sfpariswitDoria Hamelryk
 
Salesforce Starter Kit
Salesforce Starter KitSalesforce Starter Kit
Salesforce Starter KitDoria Hamelryk
 
Comment se préparer pour les certifications Salesforce
Comment se préparer pour les certifications SalesforceComment se préparer pour les certifications Salesforce
Comment se préparer pour les certifications SalesforceDoria Hamelryk
 
Comment l'automatisation dans Salesforce peut vous faciliter la vie
Comment l'automatisation dans Salesforce peut vous faciliter la vieComment l'automatisation dans Salesforce peut vous faciliter la vie
Comment l'automatisation dans Salesforce peut vous faciliter la vieDoria Hamelryk
 
Girls, What's Next? - Première rencontre du groupe
Girls, What's Next? - Première rencontre du groupeGirls, What's Next? - Première rencontre du groupe
Girls, What's Next? - Première rencontre du groupeDoria Hamelryk
 
Einstein Next Best Action - French Touch Dreamin 2019
Einstein Next Best Action - French Touch Dreamin 2019Einstein Next Best Action - French Touch Dreamin 2019
Einstein Next Best Action - French Touch Dreamin 2019Doria Hamelryk
 

More from Doria Hamelryk (20)

Salesforce Release Spring 24 - French Gathering
Salesforce Release Spring 24 - French GatheringSalesforce Release Spring 24 - French Gathering
Salesforce Release Spring 24 - French Gathering
 
Winter 22 release
Winter 22 releaseWinter 22 release
Winter 22 release
 
Apex for Admins Workshop
Apex for Admins WorkshopApex for Admins Workshop
Apex for Admins Workshop
 
Concours Trailblazers be Certified
Concours Trailblazers be Certified Concours Trailblazers be Certified
Concours Trailblazers be Certified
 
+10 of Our Favorite Salesforce Spring ’21 Features
+10 of Our Favorite Salesforce Spring ’21 Features+10 of Our Favorite Salesforce Spring ’21 Features
+10 of Our Favorite Salesforce Spring ’21 Features
 
Découverte d'Einstein Analytics (Tableau CRM)
Découverte d'Einstein Analytics (Tableau CRM)Découverte d'Einstein Analytics (Tableau CRM)
Découverte d'Einstein Analytics (Tableau CRM)
 
Odaseva : un outil de gestion pour les règles RGPD
Odaseva : un outil de gestion pour les règles RGPDOdaseva : un outil de gestion pour les règles RGPD
Odaseva : un outil de gestion pour les règles RGPD
 
Opportunity Management workshop
Opportunity Management workshopOpportunity Management workshop
Opportunity Management workshop
 
A la découverte de pardot
A la découverte de pardotA la découverte de pardot
A la découverte de pardot
 
Flows - what you should know before implementing
Flows - what you should know before implementingFlows - what you should know before implementing
Flows - what you should know before implementing
 
Gérer ses campagnes marketing
Gérer ses campagnes marketingGérer ses campagnes marketing
Gérer ses campagnes marketing
 
10 of Our Favorite Salesforce Winter ’21 Features
10 of Our Favorite Salesforce Winter ’21 Features10 of Our Favorite Salesforce Winter ’21 Features
10 of Our Favorite Salesforce Winter ’21 Features
 
Les formules et moi, ça fait 3!
Les formules et moi, ça fait 3!Les formules et moi, ça fait 3!
Les formules et moi, ça fait 3!
 
Salesforce Import Tools
Salesforce Import ToolsSalesforce Import Tools
Salesforce Import Tools
 
Concours Ladies be Certified #sfpariswit
Concours Ladies be Certified #sfpariswitConcours Ladies be Certified #sfpariswit
Concours Ladies be Certified #sfpariswit
 
Salesforce Starter Kit
Salesforce Starter KitSalesforce Starter Kit
Salesforce Starter Kit
 
Comment se préparer pour les certifications Salesforce
Comment se préparer pour les certifications SalesforceComment se préparer pour les certifications Salesforce
Comment se préparer pour les certifications Salesforce
 
Comment l'automatisation dans Salesforce peut vous faciliter la vie
Comment l'automatisation dans Salesforce peut vous faciliter la vieComment l'automatisation dans Salesforce peut vous faciliter la vie
Comment l'automatisation dans Salesforce peut vous faciliter la vie
 
Girls, What's Next? - Première rencontre du groupe
Girls, What's Next? - Première rencontre du groupeGirls, What's Next? - Première rencontre du groupe
Girls, What's Next? - Première rencontre du groupe
 
Einstein Next Best Action - French Touch Dreamin 2019
Einstein Next Best Action - French Touch Dreamin 2019Einstein Next Best Action - French Touch Dreamin 2019
Einstein Next Best Action - French Touch Dreamin 2019
 

Recently uploaded

Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

Ecrire son premier Trigger (et les comprendre)

  • 1.
  • 2. Fatima Arrou Salesforce Consultant & Developer @ BOUYGUES IMMOBILIER Mirela Smajovic Salesforce Consultant @UP Crm Sit Amet @ Consectetur
  • 4. Agenda 1. What’s an Apex Trigger ? 2. When to use Apex Trigger? 3. What are types of Trigger? 4. Basic Syntax of Trigger 5. Difference between Trigger.New and Trigger.Old 6. Trigger example 7. Summer ’20 : New Flows Features 8. Quiz
  • 5. Apex : langage de programmation utilisé sur la plateforme Salesforce. Script : portion de code permettant d’effectuer un traitement spécifique. Method : script identifié par un nom, inclus dans une classe, exécutable depuis n’importe où dans d’autres scripts. SOQL (Salesforce Object Query Language) : langage permettant d’accéder aux enregistrements dans les objets. Query : instruction écrite dans le langage SOQL (sélection d’enregistrements) Before we begin, a bit of vocabulary
  • 6. What’s an Apex Trigger?
  • 7. What’s an Apex Trigger? A trigger is an Apex script that executes before or after data manipulation language (DML) events occur. Apex triggers enable you to perform custom actions before or after events to record in Salesforce, such as insertions, updates, or deletions.
  • 8. DML (Data Manipulation Language) : opération permettant de faire des… Insert/Update : insérer / mettre à jour Upsert : mettre à jour les enregistrements s’ils existent, et ajouter les nouveaux, dans une même opération Delete/Undelete : supprimer un enregistrement / annuler la suppression Merge : fusionner deux enregistrements What is a DML?
  • 9. When to use Apex Trigger
  • 10. The benefit of using Apex Trigger ● Perform operations according to specific conditions ● Prevent certain operations from being executed ● Modify associated records ● Execute all possible actions in Apex, including executing SOQL and DML queries ● Call custom Apex methods.
  • 11. •It is a piece of code which is executed either before or after a record is updated or inserted. •150 DML operations can be used in a single trigger. •50 000 is maximum number of records retrieved by SOQL queries •You can access triggers across an object and related to that object. Salesforce Trigger
  • 12. Salesforce Trigger vs. Workflows •Workflows cannot create or update a separate object. •You can’t reference certain fields when using workflows. •You will not have your workflow doing more than just field updates and emails.
  • 13. Salesforce Trigger vs. Process Builder •Process Builders cannot handle before DML It executes after a record has been created or updated. Whereas Apex triggers can handle both before and after DML operations. •Process Builder cannot handle delete and undelete DML. Whereas Apex triggers can handle all DML operations.
  • 15. Types Of triggers Before Trigger After Trigger is used to either update or validate the values of a record before they can be saved into the database. is used to access the field values set by the system and affect any change in the record.
  • 17. Basic Syntax of Trigger
  • 18. Basic Syntax of Trigger trigger_events can be a comma-separated list of one or more of the following events: ● Before insert ● Before update ● Before delete ● After insert ● After update ● After delete ● After undelete
  • 19. Basic Syntax of Trigger
  • 21. Context variables What’s context variable ? → provide access to the records that caused the trigger fired Trigger.new Trigger.old Contains all the records that were inserted in insert or update triggers Provides the old version of sObjects before they were updated in update triggers, or a list of deleted sObjects in delete triggers
  • 22. Context variables Triggers fired when one record or many records are inserted/updated Context variable can contain one or many records You can iterate over Trigger.New to get each individual sObject Ex 1: Insert one account → Trigger.new contain one record → Iteration on one record Ex 2: Insert 10 accounts → Trigger.new contain 10 records → Iteration on 10 records X10
  • 23. How to write a trigger ? Ex from developer console
  • 24. How to write a trigger ?
  • 25. How to write a trigger ?
  • 26. How to write a trigger ?
  • 27. With a real example ?
  • 28. Need to deactivate opportunities related to an inactive account We want that when the Account active field changes to “No”, we deactivate all related opportunities Account Active : Yes ⇒ No Opportunity 1 Active : Yes ⇒ No Opportunity 2 Active : Yes ⇒ No
  • 30. Update on Account (field Active__c : Yes → No) Iteration on updated record Active field of updated record = ‘No’ ? If ok → Add account Id in a list Get Account Id Get related opp Get all related opportunities in a list Update active field on Opp Iteration on all related Opp Change value of active field on Opp Add updated Opp to a list Update the list
  • 31. In Summer ’20 : New Flows Features In Summer ’20 there is a couple of major updates; firstly you can now trigger a flow after a record is saved, in the same way a Before Trigger works in Apex. You also have an easy way to kick off a Flow, with the new and improved Start Element. Flow is receiving a huge amount of attention from Salesforce, creating a declarative tool that allows Admins to build Apex like functions.
  • 32.
  • 33. Trailhead Learning Summer ‘20 release notes : https://releasenotes.docs.salesforce.com/en-us/summer20/release-notes/rn_forcecom_flow_fbuilder_after-save_trigger.htm Apex Triggers : https://trailhead.salesforce.com/en/content/learn/modules/apex_triggers Apex Basics & Database : https://trailhead.salesforce.com/en/content/learn/modules/apex_database Quick Start: Apex Coding for Admins : https://trailhead.salesforce.com/en/content/learn/projects/quick-start-apex-coding-for-admins
  • 34. Upcoming Meeting Thu, Jun 11, 6:00 PM (CEST) Intégration Continue et Couverture de Test Avec GitHub Actions et Codecov.io Paris, FR Developers Group https://trailblazercommunitygroups.com/events/details/salesforce-paris-fr-developers-group-presents-integration-continue-et- couverture-de-test-avec-github-actions-et-codecovio/#/
  • 35.
  • 36.
  • 37.