SlideShare a Scribd company logo
1 of 29
A 5-Step Framework to Tackling Your 
First Trigger With Confidence 
(a play in 5 acts) 
Veronica Beck 
@Twitter Handle 
Ashima Saigal 
@gandhilover
Safe Harbor 
Safe harbor statement under the Private Securities Litigation Reform Act of 1995: 
This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of 
the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking 
statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service 
availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future 
operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of 
our services. 
The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, 
new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or 
delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and 
acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and 
manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization 
and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our 
annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and 
others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. 
Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be 
delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. 
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
Overview
Cast
Ashima Saigal 
is the founder of Database Sherpa. She is a 
certified Salesforce Administrator, Force.com 
Developer & Summer 2014 MVP.
Veronica Beck 
is a certified Force.com Developer, and a 
consultant with Bigger Boat Consulting in 
Seattle.
Setting 
Running time is exactly 40 minutes with no intermission 
The setting: a nonprofit yoga studio that offers teacher trainings and 
workshops. They track their trainings as campaigns, with the people 
they invite and who attend as campaign members. Campaign 
member statuses they use are "Invited; Accepted; Attended; No 
Show. As an aside, they also use campaigns to track their 
fundraising events and mailings. 
Director: Ashima Saigal 
Writer/Producer: Veronica Beck 
Grip: Salesforce.com
Audience Participation 
We have some suggestions: 
● Breathe! You can do it. 
● Replace trepidation with curiosity. 
● Know this won’t happen overnight. 
● Remember, you are not alone.
Triggers with Confidence 
Act 1: Set up Your Environment 
Act 2: Gather Your Resources 
Act 3: Clarify Your Requirements 
Act 4: Code and Test 
Act 5: Finalize and Launch!
Act 1: Set up Your Environment (Where do I write 
code??) 
Developer Org: https://developer.salesforce.com/gettingstarted
Act 1: Where do I write code?? (continued)
Act 1: Where do I write code?? (continued) 
Once you have an org, either a free Developer org or a 
sandbox, navigate to the Trigger area of the object you 
want to write the trigger on.
Act 1: Where do I write code?? (continued) 
Click the New button, and voila!
Act 2: Help! (Gather your resources) 
Salesforce coding lessons for the 99%: http://www.sfdc99.com/ 
Power of Us HUB (nonprofits): 
http://www.salesforcefoundation.org/help/power-of-us-hub/ 
Success Community: (Salesforce online community) 
Local User Groups (in person meetings) 
Developer User Groups (in person meetings) 
Network at Dreamforce!
Act 3: Clarify Requirements 
● What problem are you trying to solve? 
o Inconsistent campaign member statuses 
● What needs to happen? 
o Auto creation of desired member statuses 
● When does it need to happen? 
o When a new campaign is created 
● Should it always happen for all records? 
o Only for workshop type campaigns
Act 3: Clarify Requirements (continued) 
Write it “In English” (aka pseudo code): 
When a campaign is inserted 
● Check if it’s a workshop campaign 
● If it is a workshop campaign … 
o Get rid of the default Campaign Statuses 
o Add the following campaign statuses: 
 Invited (default) 
 Accepted (responded) 
 Attended (responded) 
 No Show
Act 4: Dive in! Code and Test 
● Recap 
o Know where to code, set up your environment 
o Go through some tutorials, gather resources 
o Clarify what you’re trying to do 
● Search for code, copy and paste!
Act 4: Dive in! Code and Test (continued)
Act 4: Dive in! Code and Test (continued)
Act 4: Dive in! Code and Test (continued)
Act 4: Dive in! Code and Test (continued) 
When a campaign is inserted 
● If it is a workshop campaign 
● Get rid of the default 
Campaign Statuses 
● Add the following 
campaign statuses: 
o Invited (default) 
o Accepted 
(responded) 
o Attended 
(responded) 
o No Show
Act 4: Dive in! Code and Test (continued)
Act 4: Dive in! Code and Test (continued)
Act 4: Dive in! Code and Test (continued)
Act 4: Dive in! Code and Test (Summary) 
● Common design elements 
o Loop through trigger.new (or trigger.old) 
o Use collections to hold records to process 
o Do inserts, updates, and deletes outside of your loops 
● Other helpful Tips 
o Comment your code! 
o Use system.debug for troubleshooting
Act 5: Finalize and Launch 
● More testing - ask users to test 
● Revise again 
● Are you ready to go live? 
o Test coverage and test classes 
o Deploy errors, keep trying. Get help.
That’s a Wrap 
Applause with standing ovation 
Encore Encore Encore
Resources 
Beginner Tutorial - http://www.sfdc99.com/beginner-tutorials/ 
Salesforce Developer Forum - https://developer.salesforce.com/forums/ 
Trigger Best Practices - http://www.iterativelogic.com/salesforce-apex-trigger-best-practices/ 
Trigger Order of Execution - 
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execu 
tion.htm 
Writing Bulk Triggers - http://blog.jeffdouglas.com/2009/04/20/writing-bulk-triggers-for-salesforce/ 
Force.com Apex Developer Guide - 
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm
Triggers for Admins: A Five-step Framework for Creating Triggers

More Related Content

Similar to Triggers for Admins: A Five-step Framework for Creating Triggers

Welcome to the Partner Community: Success Through Collaboration! (October 13,...
Welcome to the Partner Community: Success Through Collaboration! (October 13,...Welcome to the Partner Community: Success Through Collaboration! (October 13,...
Welcome to the Partner Community: Success Through Collaboration! (October 13,...Salesforce Partners
 
Release Management: Managing Your Internal Releases
Release Management: Managing Your Internal ReleasesRelease Management: Managing Your Internal Releases
Release Management: Managing Your Internal ReleasesJoshua Hoskins
 
How to Create Awesome Documentation
How to Create Awesome DocumentationHow to Create Awesome Documentation
How to Create Awesome DocumentationSalesforce Admins
 
APP Academy: Marketing (Virtual Classroom)
APP Academy: Marketing (Virtual Classroom)APP Academy: Marketing (Virtual Classroom)
APP Academy: Marketing (Virtual Classroom)Salesforce Partners
 
Marketing Effectively to Drive Adoption and Compliance Using Flow - Jeremiah ...
Marketing Effectively to Drive Adoption and Compliance Using Flow - Jeremiah ...Marketing Effectively to Drive Adoption and Compliance Using Flow - Jeremiah ...
Marketing Effectively to Drive Adoption and Compliance Using Flow - Jeremiah ...Salesforce Admins
 
Pro Bono Volunteering with Salesforce Nonprofit Customers
Pro Bono Volunteering with Salesforce Nonprofit CustomersPro Bono Volunteering with Salesforce Nonprofit Customers
Pro Bono Volunteering with Salesforce Nonprofit CustomersSalesforce Developers
 
APP Academy: Sales (Virtual Classroom) - slides
APP Academy: Sales (Virtual Classroom) - slidesAPP Academy: Sales (Virtual Classroom) - slides
APP Academy: Sales (Virtual Classroom) - slidesSalesforce Partners
 
Circles of success - So you have created or acquired a mess - now what (1)
Circles of success - So you have created or acquired a mess - now what (1)Circles of success - So you have created or acquired a mess - now what (1)
Circles of success - So you have created or acquired a mess - now what (1)Salesforce - Sweden, Denmark, Norway
 
Cloud Academy: Getting Started (June 17, 2015)
Cloud Academy: Getting Started (June 17, 2015)Cloud Academy: Getting Started (June 17, 2015)
Cloud Academy: Getting Started (June 17, 2015)Salesforce Partners
 
How to Make a Career as an Admin by Denise Carbone
How to Make a Career as an Admin by Denise CarboneHow to Make a Career as an Admin by Denise Carbone
How to Make a Career as an Admin by Denise CarboneSalesforce Admins
 
APP Academy: Marketing (Virtual Classroom)
APP Academy: Marketing (Virtual Classroom)APP Academy: Marketing (Virtual Classroom)
APP Academy: Marketing (Virtual Classroom)Salesforce Partners
 
Build Your Lightning Rollout Plan - September 2017
Build Your Lightning Rollout Plan - September 2017Build Your Lightning Rollout Plan - September 2017
Build Your Lightning Rollout Plan - September 2017Salesforce Admins
 
3 Ways to Increase Executive Adoption of Salesforce
3 Ways to Increase Executive Adoption of Salesforce3 Ways to Increase Executive Adoption of Salesforce
3 Ways to Increase Executive Adoption of SalesforceSalesforce Admins
 
Circles of success - How to successfully transition to lightning (2)
Circles of success - How to successfully transition to lightning (2)Circles of success - How to successfully transition to lightning (2)
Circles of success - How to successfully transition to lightning (2)Salesforce - Sweden, Denmark, Norway
 
How to Rock a Salesforce Demo (and why it matters)
How to Rock a Salesforce Demo (and why it matters)How to Rock a Salesforce Demo (and why it matters)
How to Rock a Salesforce Demo (and why it matters)Salesforce Admins
 
Partner Community Office Hours (July 2, 2015)
Partner Community Office Hours (July 2, 2015)Partner Community Office Hours (July 2, 2015)
Partner Community Office Hours (July 2, 2015)Salesforce Partners
 
Essential Habits for New Admins 2017
Essential Habits for New Admins 2017Essential Habits for New Admins 2017
Essential Habits for New Admins 2017Salesforce Admins
 
Supercharge your License Management - Salesforce AppExchange
Supercharge your License Management - Salesforce AppExchangeSupercharge your License Management - Salesforce AppExchange
Supercharge your License Management - Salesforce AppExchangeEric Wu
 
Essential habits for New Admins 02.18
Essential habits for New Admins 02.18Essential habits for New Admins 02.18
Essential habits for New Admins 02.18Salesforce Admins
 

Similar to Triggers for Admins: A Five-step Framework for Creating Triggers (20)

Welcome to the Partner Community: Success Through Collaboration! (October 13,...
Welcome to the Partner Community: Success Through Collaboration! (October 13,...Welcome to the Partner Community: Success Through Collaboration! (October 13,...
Welcome to the Partner Community: Success Through Collaboration! (October 13,...
 
Release Management: Managing Your Internal Releases
Release Management: Managing Your Internal ReleasesRelease Management: Managing Your Internal Releases
Release Management: Managing Your Internal Releases
 
How to Create Awesome Documentation
How to Create Awesome DocumentationHow to Create Awesome Documentation
How to Create Awesome Documentation
 
APP Academy: Marketing (Virtual Classroom)
APP Academy: Marketing (Virtual Classroom)APP Academy: Marketing (Virtual Classroom)
APP Academy: Marketing (Virtual Classroom)
 
Marketing Effectively to Drive Adoption and Compliance Using Flow - Jeremiah ...
Marketing Effectively to Drive Adoption and Compliance Using Flow - Jeremiah ...Marketing Effectively to Drive Adoption and Compliance Using Flow - Jeremiah ...
Marketing Effectively to Drive Adoption and Compliance Using Flow - Jeremiah ...
 
Pro Bono Volunteering with Salesforce Nonprofit Customers
Pro Bono Volunteering with Salesforce Nonprofit CustomersPro Bono Volunteering with Salesforce Nonprofit Customers
Pro Bono Volunteering with Salesforce Nonprofit Customers
 
APP Academy: Sales (Virtual Classroom) - slides
APP Academy: Sales (Virtual Classroom) - slidesAPP Academy: Sales (Virtual Classroom) - slides
APP Academy: Sales (Virtual Classroom) - slides
 
Circles of success - So you have created or acquired a mess - now what (1)
Circles of success - So you have created or acquired a mess - now what (1)Circles of success - So you have created or acquired a mess - now what (1)
Circles of success - So you have created or acquired a mess - now what (1)
 
Cloud Academy: Getting Started (June 17, 2015)
Cloud Academy: Getting Started (June 17, 2015)Cloud Academy: Getting Started (June 17, 2015)
Cloud Academy: Getting Started (June 17, 2015)
 
How to Make a Career as an Admin by Denise Carbone
How to Make a Career as an Admin by Denise CarboneHow to Make a Career as an Admin by Denise Carbone
How to Make a Career as an Admin by Denise Carbone
 
APP Academy: Marketing (Virtual Classroom)
APP Academy: Marketing (Virtual Classroom)APP Academy: Marketing (Virtual Classroom)
APP Academy: Marketing (Virtual Classroom)
 
Build Your Lightning Rollout Plan - September 2017
Build Your Lightning Rollout Plan - September 2017Build Your Lightning Rollout Plan - September 2017
Build Your Lightning Rollout Plan - September 2017
 
The Apex Interactive Debugger
The Apex Interactive DebuggerThe Apex Interactive Debugger
The Apex Interactive Debugger
 
3 Ways to Increase Executive Adoption of Salesforce
3 Ways to Increase Executive Adoption of Salesforce3 Ways to Increase Executive Adoption of Salesforce
3 Ways to Increase Executive Adoption of Salesforce
 
Circles of success - How to successfully transition to lightning (2)
Circles of success - How to successfully transition to lightning (2)Circles of success - How to successfully transition to lightning (2)
Circles of success - How to successfully transition to lightning (2)
 
How to Rock a Salesforce Demo (and why it matters)
How to Rock a Salesforce Demo (and why it matters)How to Rock a Salesforce Demo (and why it matters)
How to Rock a Salesforce Demo (and why it matters)
 
Partner Community Office Hours (July 2, 2015)
Partner Community Office Hours (July 2, 2015)Partner Community Office Hours (July 2, 2015)
Partner Community Office Hours (July 2, 2015)
 
Essential Habits for New Admins 2017
Essential Habits for New Admins 2017Essential Habits for New Admins 2017
Essential Habits for New Admins 2017
 
Supercharge your License Management - Salesforce AppExchange
Supercharge your License Management - Salesforce AppExchangeSupercharge your License Management - Salesforce AppExchange
Supercharge your License Management - Salesforce AppExchange
 
Essential habits for New Admins 02.18
Essential habits for New Admins 02.18Essential habits for New Admins 02.18
Essential habits for New Admins 02.18
 

More from Salesforce Developers

Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSalesforce Developers
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceMaximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceSalesforce Developers
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base ComponentsSalesforce Developers
 
TrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsTrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsSalesforce Developers
 
Why developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaWhy developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaSalesforce Developers
 
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentCodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentSalesforce Developers
 
CodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsCodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsSalesforce Developers
 
Enterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsEnterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsSalesforce Developers
 
TrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsTrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsSalesforce Developers
 
Lightning web components - Episode 4 : Security and Testing
Lightning web components  - Episode 4 : Security and TestingLightning web components  - Episode 4 : Security and Testing
Lightning web components - Episode 4 : Security and TestingSalesforce Developers
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilitySalesforce Developers
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce dataSalesforce Developers
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionSalesforce Developers
 
Migrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPMigrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPSalesforce Developers
 
Scale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceScale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceSalesforce Developers
 
Replicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureReplicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureSalesforce Developers
 
Modern Development with Salesforce DX
Modern Development with Salesforce DXModern Development with Salesforce DX
Modern Development with Salesforce DXSalesforce Developers
 
Integrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectIntegrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectSalesforce Developers
 

More from Salesforce Developers (20)

Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceMaximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component Performance
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base Components
 
TrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsTrailheaDX India : Developer Highlights
TrailheaDX India : Developer Highlights
 
Why developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaWhy developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX India
 
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentCodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local Development
 
CodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsCodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web Components
 
Enterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsEnterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web Components
 
TrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsTrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer Highlights
 
Live coding with LWC
Live coding with LWCLive coding with LWC
Live coding with LWC
 
Lightning web components - Episode 4 : Security and Testing
Lightning web components  - Episode 4 : Security and TestingLightning web components  - Episode 4 : Security and Testing
Lightning web components - Episode 4 : Security and Testing
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura Interoperability
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce data
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An Introduction
 
Migrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPMigrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCP
 
Scale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceScale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in Salesforce
 
Replicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureReplicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data Capture
 
Modern Development with Salesforce DX
Modern Development with Salesforce DXModern Development with Salesforce DX
Modern Development with Salesforce DX
 
Get Into Lightning Flow Development
Get Into Lightning Flow DevelopmentGet Into Lightning Flow Development
Get Into Lightning Flow Development
 
Integrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectIntegrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS Connect
 

Recently uploaded

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
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
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 

Recently uploaded (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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...
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 

Triggers for Admins: A Five-step Framework for Creating Triggers

  • 1. A 5-Step Framework to Tackling Your First Trigger With Confidence (a play in 5 acts) Veronica Beck @Twitter Handle Ashima Saigal @gandhilover
  • 2. Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
  • 5. Ashima Saigal is the founder of Database Sherpa. She is a certified Salesforce Administrator, Force.com Developer & Summer 2014 MVP.
  • 6. Veronica Beck is a certified Force.com Developer, and a consultant with Bigger Boat Consulting in Seattle.
  • 7. Setting Running time is exactly 40 minutes with no intermission The setting: a nonprofit yoga studio that offers teacher trainings and workshops. They track their trainings as campaigns, with the people they invite and who attend as campaign members. Campaign member statuses they use are "Invited; Accepted; Attended; No Show. As an aside, they also use campaigns to track their fundraising events and mailings. Director: Ashima Saigal Writer/Producer: Veronica Beck Grip: Salesforce.com
  • 8. Audience Participation We have some suggestions: ● Breathe! You can do it. ● Replace trepidation with curiosity. ● Know this won’t happen overnight. ● Remember, you are not alone.
  • 9. Triggers with Confidence Act 1: Set up Your Environment Act 2: Gather Your Resources Act 3: Clarify Your Requirements Act 4: Code and Test Act 5: Finalize and Launch!
  • 10. Act 1: Set up Your Environment (Where do I write code??) Developer Org: https://developer.salesforce.com/gettingstarted
  • 11. Act 1: Where do I write code?? (continued)
  • 12. Act 1: Where do I write code?? (continued) Once you have an org, either a free Developer org or a sandbox, navigate to the Trigger area of the object you want to write the trigger on.
  • 13. Act 1: Where do I write code?? (continued) Click the New button, and voila!
  • 14. Act 2: Help! (Gather your resources) Salesforce coding lessons for the 99%: http://www.sfdc99.com/ Power of Us HUB (nonprofits): http://www.salesforcefoundation.org/help/power-of-us-hub/ Success Community: (Salesforce online community) Local User Groups (in person meetings) Developer User Groups (in person meetings) Network at Dreamforce!
  • 15. Act 3: Clarify Requirements ● What problem are you trying to solve? o Inconsistent campaign member statuses ● What needs to happen? o Auto creation of desired member statuses ● When does it need to happen? o When a new campaign is created ● Should it always happen for all records? o Only for workshop type campaigns
  • 16. Act 3: Clarify Requirements (continued) Write it “In English” (aka pseudo code): When a campaign is inserted ● Check if it’s a workshop campaign ● If it is a workshop campaign … o Get rid of the default Campaign Statuses o Add the following campaign statuses:  Invited (default)  Accepted (responded)  Attended (responded)  No Show
  • 17. Act 4: Dive in! Code and Test ● Recap o Know where to code, set up your environment o Go through some tutorials, gather resources o Clarify what you’re trying to do ● Search for code, copy and paste!
  • 18. Act 4: Dive in! Code and Test (continued)
  • 19. Act 4: Dive in! Code and Test (continued)
  • 20. Act 4: Dive in! Code and Test (continued)
  • 21. Act 4: Dive in! Code and Test (continued) When a campaign is inserted ● If it is a workshop campaign ● Get rid of the default Campaign Statuses ● Add the following campaign statuses: o Invited (default) o Accepted (responded) o Attended (responded) o No Show
  • 22. Act 4: Dive in! Code and Test (continued)
  • 23. Act 4: Dive in! Code and Test (continued)
  • 24. Act 4: Dive in! Code and Test (continued)
  • 25. Act 4: Dive in! Code and Test (Summary) ● Common design elements o Loop through trigger.new (or trigger.old) o Use collections to hold records to process o Do inserts, updates, and deletes outside of your loops ● Other helpful Tips o Comment your code! o Use system.debug for troubleshooting
  • 26. Act 5: Finalize and Launch ● More testing - ask users to test ● Revise again ● Are you ready to go live? o Test coverage and test classes o Deploy errors, keep trying. Get help.
  • 27. That’s a Wrap Applause with standing ovation Encore Encore Encore
  • 28. Resources Beginner Tutorial - http://www.sfdc99.com/beginner-tutorials/ Salesforce Developer Forum - https://developer.salesforce.com/forums/ Trigger Best Practices - http://www.iterativelogic.com/salesforce-apex-trigger-best-practices/ Trigger Order of Execution - http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execu tion.htm Writing Bulk Triggers - http://blog.jeffdouglas.com/2009/04/20/writing-bulk-triggers-for-salesforce/ Force.com Apex Developer Guide - http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm

Editor's Notes

  1. Key Takeaway: We are a publicly traded company. Please make your buying decisions only on the products commercially available from Salesforce.com. Talk Track: Before I begin, just a quick note that when considering future developments, whether by us or with any other solution provider, you should always base your purchasing decisions on what is currently available.
  2. Welcome ... we’re excited to be here ... this session is "A five step framework to Tackling your First Trigger With Confidence..." It's geared towards Salesforce admins who have never written code in any programming language, and are trying to figure out how to get started. Show of hands from those who have never written any apex code. Show of hands of people who have a specific business need that they need code for. Show of hands from people who are wanting to expand their skill set. All of you are in the right place. What you'll get out of today's session is: - Practical steps for how to get started with Apex - Resources for how to continue once you leave here - Confidence to get in there and start coding! And now, sit back, relax, and enjoy our Production of “Triggers with Confidence”, a play with 5 acts.
  3. Welcome ... we’re excited to be here ... this session is "A five step framework to Tackling your First Trigger With Confidence..." It's geared towards Salesforce admins who have never written code in any programming language, and are trying to figure out how to get started. Show of hands from those who have never written any apex code. Show of hands of people who have a specific business need that they need code for. Show of hands from people who are wanting to expand their skill set. All of you are in the right place. What you'll get out of today's session is: - Practical steps for how to get started with Apex - Resources for how to continue once you leave here - Confidence to get in there and start coding! And now, sit back, relax, and enjoy our Production of “Triggers with Confidence”, a play with 5 acts.
  4. VERONICA: The setting for our play is a yoga studio that offers workshops. They track their workshops with Salesforce campaigns, and they track the people they invite by using campaign members. They’re finding that the standard Campaign member Statuses of Invited and Sent aren’t what they need. They want their own custom campaign member statuses, but it’s a pain to have to add them every time. Veronica has been asked by the studio manager to find a solution to this problem.
  5. VERONICA: To get the most out of this production, we have some suggestions for you: First is: Breathe! You can do it. Everyone has to start somewhere, and Next: See if you can start to replace any feelings of trepidation with a sense of curiosity and exploration. If you tend to think "What if I get it wrong???" Don't worry, you will! But that's ok. You won't break Salesforce. And you'll learn a lot along the way. If you can focus on the learning, and the adventure of it, it will be a lot more enjoyable. Also: Know this won't happen overnight .... it takes time, and practice. And that's ok. Little by little you’ll get there. Finally: Remember, you're not alone! There are wonderful people in the Salesforce community who are generous with their time and help. and plenty of resources to help you out along the way.
  6. VERONICA: Our play is in 5 acts: Act 1: Set up your environment, or Where do I write code? [TRANSITION] Act 2: Gather Your Resources (Get help!) Act 3: Clarify Your Requirements: What am I doing again? Act 4: Code and Test! Act 5:Finalize and launch! Let’s, start by taking 3 deep breaths to get transported to the yoga studio:
  7. ASHIMA: The scene: Ashima and Veronica met at DreamForce last year. Veronica knows that she is going to need some help, so she set up a meeting to talk about her needs. They are meeting via Google Hangout. VERONICA: Ashima, I have a Salesforce thing I’m trying to do. I want to have some different campaign member statuses added every time we create a new campaign. I thought maybe I could do it with a workflow rule, but it looks like that won’t work. So I think I’m going to need to write a trigger. I have no idea how to get started. I don’t even know where in Salesforce I would write code, let alone what to write. Can you help me? ASHIMA: Absolutely Veronica, first, let’s discuss some environments you might want to set up for yourself to get started. There are two options. First, you can create a Developer Org. (FREE! You can have as many as you want!) Enterprise Edition, 2 users. Terms of use are you're not supposed to run your business off of this -- it's a place where you can practice and learn. This is great if you’re in the “I want to expand my skills” camp, and don’t have an immediate need to add code to your organization. A great place to build and learn, no one else will be in it, you can do want you want, and experiment.) Even if you do have an immediate business need, this is still a great place to learn, without fear of destroying anything. :-) Considered a Production org when logging in. (login.salesforce.com, not test.salesforce.com)
  8. ASHIMA: Second, you can create a sandbox which is a copy of your production database, minus the data, unless you purchase a sandbox with data. All the custom configuration is there -- custom objects, workflow and validation rules, custom fields, picklist values, custom profiles, etc. The advantage is that you’re working in the environment you eventually want to deploy to, so if you need to work with any custom fields or objects, or want to see how workflow rules interact with the code you’re writing, it’s already set up. You must deploy from a sandbox, so you can get started in a development organization, but then, you must move your code to a sandbox and deploy to production from there. Some of the nonprofit developers knows that you can get a few free sandboxes with your edition. If you are not a nonprofit, that is not available free. Disadvantages: Cost. [info about cost here] Less storage space. VERONICA: What does deploy mean? ASHIMA : It means moving your code from the testing environment to a live, production environment, but we have a few more steps before you can do that, we’ll get to deployment. VERONICA: {Deep breath}, okay.
  9. ASHIMA: So, now, once you have your environment set up, you will want to begin to play around. I suggest you do this in your sandbox, since you’re a nonprofit and have a few free sandboxes to play with. Now to begin writing your code, start by navigating to the Trigger area of the object you want to write your Trigger on. VERONICA:The campaign member? ASHIMA: Well, that might seem like where you’d want to write the trigger, but think about it for a second -- what do you want to happen? VERONICA: I want to add new campaign member statuses. ASHIMA: And when do you want to create them? VERONICA: When we add a new campaign. ASHIMA: Ok, so where would you want to create the trigger? VERONICA: [pause] Oh … the campaign, right? Because it’s like a workflow rule - I want the trigger code to run when a Campaign is created. ASHIMA: Right! VERONICA: Ok, that makes sense.
  10. ASHIMA: Alright, now to write your code, you click on the Trigger and click the New button. The code area opened up and I can begin writing. VERONICA: Ok, at least I know where to start. ASHIMA: Yes. And just so you know, doing your coding right here in Salesforce is a quick and easy way to get started, but once you get more familiar with how everything works, you might also want to check out some of the other tools people use to write code. For example, the Salesforce Developer Console, Eclipse, or Workbench. Those tools offer some great functionality, but there’s also a learning curve with them. So for now, let’s stick to doing our coding here within Salesforce. VERONICA: Okay, but I’m nervous about this - it seems like there’s a lot to learn! ASHIMA: It’s okay to be nervous Veronica. But, I’ll help and there are a lot of resources available. Let’s look at some together. VERONICA: Ok, sounds good!
  11. ASHIMA: The most excellent tool available is this sfdc99, which is coding lessons for the 99% (meaning for everyone who is not a programmer). This great site was written by a self-taught Google engineer, who started out as a Salesforce Admin. {Look at audience: He is also hosting a session : Wednesday 11AM – Anyone can learn to code Apex!} This blog contains a beginners tutorial that will take you step by step through the process of writing code, all the syntax you need, … plus he’s funny. Also just added a Newbies Forum, where you can ask any coding question you have. An amazing resource. VERONICA: Wow, I need to spend some time on that web site! ASHIMA: Yes, but that’s not all. There is also a great resource that is just for nonprofits called the Power of Us Hub. Join that and look for the nonprofit developer chatter group. VERONICA: I’m in there, but didn’t realize there was a developer group for nonprofits, great! ASHIMA: Yup, and I also recommend the Success community, user groups, developer user groups and to network here, at DreamForce. There are lots of folks willing to help. Along with me. VERONICA: I’m really glad to know about all these resources. ASHIMA : Now, Veronica, go ask the yoga studio manager what the specific needs are for the campaigns. The more you can get clear in your own mind about what it is you’re trying to do, the better prepared you’ll be not only to write the code, but also ask relevant questions and get help. VERONICA: I’ll do that! Thanks for your help. Namaste ASHIMA: Namaste
  12. ASHIMA: Setting: the yoga studio. I’m Celeste, the studio manager. ASHIMA: Namaste, Veronica how are you today? VERONICA: Namaste Celeste, I’m well. I wanted to ask you about the issue you mentioned with tracking our workshops in Salesforce. Can you explain to me again what’s going on? [click: What problem are you trying to solve?] ASHIMA: Yes, of course. So, you know we’re trying to track who’s coming to our trainings. I want to be able to see who’s signing up, but not showing up. It seems to be a problem lately. I think we need to start charging people ahead of time. But I’m having a hard time tracking it. Zola and Etta are entering the data, but they keep forgetting to add the right statuses, so we can’t mark someone as a No Show. [transition: inconsistent campaign member statuses] VERONICA: I made a template campaign for them that I showed them how to clone … isn’t that working? ASHIMA: They said they can never find it, or they forget to use it. It’s kind of driving me crazy. VERONICA: Hmm, ok. So, you want a way for those statuses to be there without anyone having to manually go in and create them? ASHIMA: Yes, that would be great! VERONICA: And we’re talking about the campaign member statuses, right? ASHIMA: I don’t know what you call it, I just need a way to track who shows up and who doesn’t. VERONICA: Ok. ASHIMA: Oh, and I want to know who we’re inviting in the first place, and who lets us know they’re coming. And who actually came. Along with who said they were coming but didn’t. VERONICA: Ok. So, it sounds like it would work to maybe have these statuses you could see: Invited, Accepted, Attended, and No Show? ASHIMA: Yes! VERONICA: Great, I think I have it. ASHIMA: So, do you think you can have it done this week? You can just set Salesforce up to do that, right? How hard can it be??? VERONICA: Well …it’s going to involve actual coding, so I’m going to have to take some time to learn how to do it. But the good news is, it’s a great thing for me to learn, and it will really help us out in the long run. ASHIMA: [Sigh]. Ok, do what you have to do. VERONICA: Ok. Oh wait, one more question … this is only for trainings and workshops, right? Not for our mailings, right? ASHIMA: Just the workshops. VERONICA: Ok, got it.
  13. ASHIMA: Veronica and Ashima meet on Google Hangout VERONICA: Ok Ashima, I talked to my studio manager and I think I know what needs to happen now. What’s next? How do I figure out how to write the trigger? ASHIMA: Before I write the actual code, I usually write “pseudo code” , which is writing out at a high level, in English, what the code needs to do. It helps me clarify my thoughts on how to structure the code. VERONICA: Can you show me what you mean? ASHIMA: Sure. Here’s what some pseudo code might look like for your trigger. [transition: show pseudo code]
  14. VERONICA: Ok, so now I know: Where to write the code -- in my sandbox, or in a developer org. I’ve gone through some of the great sfdc99 tutorials, and I know other resources I can use to help me I have an idea of what I want my code to do … I’ve written it out in English, and I’ve thought about what should happen when. I guess it’s time to start coding! I’m going to start by doing a search to see if there’s some sample code out there that someone already wrote. Maybe I can copy and paste it. ASHIMA: That sounds like a great start Veronica. Get in touch with me when you have more questions and we can reconnection. VERONICA: Sounds good. Namaste Ashima. ASHIMA: Namaste Veronica.
  15. VERONICA: Setting: A few days later, another video chat with Ashima. Ok Ashima, I did a Google search and found a post from someone who needed to do pretty much what I’m trying to do! I don’t totally understand the code … but I went ahead and copied and pasted it, and saved it into my trigger. Can you explain what some of these things mean? For example, what is trigger.new? ASHIMA: Sure! Trigger.new is a collection that holds all of the new Campaign records that were just inserted. VERONICA: All of the campaign records? I don’t get it … aren’t I just creating one new Campaign record when I create a Campaign? ASHIMA: Yes, but what if you upload a bunch of new Campaigns with the Data Loader? VERONICA: Ohhh, I hadn’t thought of that. ASHIMA: Pretty much every trigger will follow some version of this pattern: using the trigger.new (or trigger.old) collection, looping through the collection, and doing something with the records in the collection. In this code, you’re looping through the collection of campaigns that were created, and adding new campaign member statuses to each one. VERONICA: You said there’s a trigger.old collection too? ASHIMA: Yes, that one is used in updates or deletes. It holds the old versions of the records that were updated or deleted. Trigger.new holds the new versions. VERONICA: Ok, I know I’m not going to understand all of this all at once … but I really want to test it and see if it works. How can I do that? ASHIMA: Now that you’ve saved the trigger, you can go ahead and just create a new Campaign in Salesforce, and then check the Campaign Member Statuses! VERONICA: Cool! I’m going to try that right now.
  16. VERONICA: Hey, it worked! Kind of. It looks like it added some new statuses. But I noticed a couple of things -- they’re not exactly the statuses I wanted. And those default statuses of Sent and Responded are still there. ASHIMA: Let’s tackle those issues one at a time. Let’s go back to the code, and tell me if you can find where you might change what those new statuses say. VERONICA: Ok.
  17. VERONICA: Hey, I see it right here -- these are the statuses that were added! Can I just change them to be what I want? ASHIMA: Give it a try and see! VERONICA: This is kind of fun! Oh, but they only added three statuses, and I want four. I’m guessing I can just copy and paste the code? ASHIMA: Now you’re getting the hang of it! VERONICA: Oh, and there’s an explanation right within the code of looping through the trigger.new collection here, and which statuses they’re going to add -- that’s helpful! ASHIMA: Yes, those are comments! You definitely want to get in the habit of using comments within the code to explain what’s going on. It will help anyone else who happens to look at your code … and it will help YOU, when you go back to look at code you wrote a while ago and can’t remember why you wrote it! Take the time to do it -- believe me, you’ll thank yourself later! Just use two forward slashes before any comments you want to make - that will tell the compiler it’s a comment, not code. Oh, and emember the pseudo code we wrote? I’ll often put that into my brand new trigger as comments, to give me a starting place to structure my code, and to remind me of how I want the code to work. Actually, let’s go take a look at that pseudo code now.
  18. ASHIMA: When you look at the pseudo code, and the actual code, what do you notice? VERONICA: Well … I see in our pseudo code we have “Add the following campaign statuses”, and I see where in the code that’s happening. But what about get rid of the default campaign statuses? Oh … right … that’s what we saw when we tried the code out -- that part isn’t there! ASHIMA: Right! There’s no code to delete those yet, so they showed up when you created the Campaign. Notice anything else that’s missing? VERONICA: Hmm …. we say to check if it’s a workshop campaign … but I don’t think that’s happening anywhere either, is it? ASHIMA: Good catch! See, the pseudo code can remind you of the requirements. VERONICA: Ok, it’s kind of making sense. So can we add those missing pieces? ASHIMA: Yes, I happen to have a version of the code that I think will do the trick. Let’s take a look at it.
  19. ASHIMA: Notice that the very first line of pseudo code was “After a campaign is inserted.” Here’s what that translates to in the trigger -- after insert. You define when you want your code to run. You could set your trigger to fire on more than one event -- after insert, after update, before delete, etc. There are some things you can do before insert that you can’t do after, and vise versa. Next is checking to see if it’s a workshop campaign. Here’s where we’re doing that. VERONICA: Ok, I can see that. But what are all those lists and sets for towards the top of the code? ASHIMA: That’s another common element you’ll see in triggers. Lists and sets are collections. They’re used to hold records that you’re going to process. In this trigger we’re going to have a list of campaign member statuses to delete, another list of campaign member statuses to add, and a set of campaign IDs of any workshop type Campaigns that were inserted. Don’t worry too much about these details now -- they’ll become more familiar to you as you practice. And remember, the website sfdc99.com will explain all of this in detail and give you lots of ways to practice. For now, just know that you’ll likely use lists and sets in your triggers. VERONICA: Ok. What is that part there that says “system.debug we added this campaign for processing”? What does that do? ASHIMA: System.debug is a really helpful tool. Anything you write as a system.debug statement will get written out in the debug logs. It’s a way for you to troubleshoot what’s happening in the code as it processes. In this example, for every workshop type campaign that was created, there would be a line in the debug log that said “We added this campaign for processing”, along with the campaign name. VERONICA: Where are the debug logs? ASHIMA: If you go to the Setup area and type Debug in the search, you’ll find them -- in the Monitor section. You need to set up a debug log for yourself by clicking New in the debug log area and adding your name. Then after you create a Campaign, you can look at the debug log and find your debug statement. Here, let’s take a quick look.
  20. ASHIMA: This is a snippet from the debug log. Looks like you have a workshop coming up called How to be a Zen Goddess -- I want to sign up! VERONICA: Me too! :-)
  21. ASHIMA: Ok, let’s finish looking at the rest of the code. I’ve added a section to delete the default campaign member statuses. And finally, the bottom part is where the statuses you want are created. VERONICA: Ok, there are a lot of details I still don’t get, but I get the general idea of what’s happening. This is great! I do have just one more question for now … back to those lists and sets. The “cmsToInsert” list -- it looks like you’re adding the new campaign member statuses while you’re looping through the workshop campaigns …. but then it looks like you insert them again at the bottom of the code. ASHIMA: Ah, great question. So, inside this loop is where we’re just putting things into our collection -- our “cmsToInsert” list. We’re not actually inserting them into Salesforce yet. The collection is just a storage place to hold all the records we’re going to process. Then, after we’re done going through the loop, that Insert statement at the bottom is where we’re actually creating the records in Salesforce. This is another important design pattern -- you generally want to do your inserts, updates, and deletes outside of any loops, otherwise you can run into some errors around what are called Governor Limits. Again, don’t worry too much about it now. You’ll get the hang of it with more practice. VERONICA: Ok, there’s a lot to learn! But at least I feel good about getting started.
  22. ASHIMA: Yes, there is a lot to learn, but you’re off to a great start! Here are some of the key things we talked about: In the majority of triggers you’ll be looping through trigger.new or trigger.old. Use collections to hold records you’re going to process Do your inserts, updates, and deletes outside of loops Be sure to comment your code You can use system.debug and the debug log to see what’s happening when the code runs. VERONICA: Thanks Ashima, this has been super helpful. So … now that the code’s working … can I just copy and paste it to my production org?
  23. { POSSIBLY NEED TO REWRITE DEPENDING ON THE ENDING OF ACT 4} This is the final act of our play. VERONICA: Great, it’s ready to go to production. What was that called again to move my code from sandbox into production? ASHIMA: Deploy, but there are still a few more steps I’d like to recommend before deployment.. First, it’s important to get your users to test it out. I’d recommend asking Etta and Zola to log into the Sandbox and make them go through the steps of creating some real campaigns. You never know what you might have missed in your code that the users might uncover. VERONICA: Oh, that makes sense. Okay, then are we ready to go to production? ASHIMA: Well, not yet. After they test and if they find anything, you’ll need to revise your code. And, then, ask them to retest the code again. Once they agree it’s working good, there is one final step before deployment and that’s called test coverage. You do that with something called test cases. VERONICA: Wow, there sure is a lot of testing. Seems overboard to me. ASHIMA: Actually, it’s super important to test your code as this is running realtime in the database. So, you noticed when you created a campaign, your code ran immediately. When you create test cases, it helps stop the system from getting broken. For example, if you introduced a new package or new code to your instance, it might interfere with this code. The test cases can check to make sure you don’t break your instance of Salesforce. VERONICA: I hadn’t thought about that. Well, I guess testing is pretty important. ASHIMA: Yes. I highly recommend reading up on testing just like you have done here with your coding. Take a look at the SFDC99 resource again, there is a section on testing. Also, the Developer API also offers some great suggestions as do a few other web site you can find. VERONICA: Okay, so after I do all this, how do I deploy. ASHIMA: We’ll do that, but the SFDC99 documentation has help for that, but don’t be surprised if you run into errors or trouble. But, first, we need to test with users, revise and test again and then write test classes. The deployment is really the last and final step. I’ll help you with that as well and may see what you can do on your own. VERONICA: Great, after doing this much on my own, I’m starting to feel a bit more confident. ASHIMA: That’s great Veronica, you have done an amazing job and with very little help from me. You’re on the right path and you’ve been asking some great questions. Keep it up and once you get the deployed, I need some help from you with a report I’m trying to create. VERONICA: Help from me? Don’t you know it all? ASHIMA: Not really, I know some things, but I don’t know enough about Analytics and you’re the guru I hear. So, when you have some time, can you help me? VERONICA: Of course. ASHIMA: Great. Namaste Veronica! VERONICA: Namaste Ashima!
  24. Bow to the audience (and pretend to catch flowers being thrown at us and smelling them) SMILE BROADLY.