The document outlines 10 commandments or best practices for developing on the Salesforce platform:
1. Keep code simple with the KISS principle
2. Avoid putting queries in for loops
3. Avoid putting DML operations in for loops
4. Only have one trigger per object
5. Only put trigger execution logic in triggers
6. Balance clicks vs code for a happy admin and developer
7. Use maps for efficient queries when needed
8. Leverage relationships to reduce queries
9. Aim for 100% test coverage of all code
10. Write meaningful tests that assert expected behavior
The document provides guidelines but also notes they can be broken when
Get Started with Lightning Web Components Open SourceDeveloper Force
With the announcement of Lightning Web Components (LWC) Open Source, developers can now leverage the same UI framework for building applications on Salesforce, and on any other platform. This opens up new possibilities for simpler code sharing, faster application building, and an overall better developer experience. Learn how to get started with LWC Open Source and how to build your first component.
Demystify Metadata Relationships with the Dependency APIDeveloper Force
As your org grows, the relationships between different metadata components become more complex. To understand metadata dependencies, we're happy to introduce the new Dependency API that allows queries for metadata dependencies within the org.
CodeLive with Cynthia Thomas - Refactoring data dependent code.JackGuo20
Cloning data can be harder than it looks; especially if there are multiple records. In this CodeLive session, Cynthia Thomas and Kevin Poorman work to refactor and test code to elegantly clone large numbers of records. Register now to learn about handling collections of data, refactoring, and testing practices.
Curious to know what Lightning Platform is, how you can best develop with it, or looking for specific best practices for implementation? We’ve got the Lightning Platform Product Management team on tap to address some of your most burning questions and help you build apps faster!
Your career, brand, and reputation depend on how well you deliver presentations, both internally and externally. For most people, getting up in front of an audience is a terrifying experience, but it doesn't have to be. By learning a few simple techniques, you can confidently deliver career-boosting technical presentations that won't bore an audience, accidentally tarnish your brand, or limit your career opportunities. Presenting is a craft, not a talent. Those who learn the craft can easily take their careers to the next level.
Get Started with Lightning Web Components Open SourceDeveloper Force
With the announcement of Lightning Web Components (LWC) Open Source, developers can now leverage the same UI framework for building applications on Salesforce, and on any other platform. This opens up new possibilities for simpler code sharing, faster application building, and an overall better developer experience. Learn how to get started with LWC Open Source and how to build your first component.
Demystify Metadata Relationships with the Dependency APIDeveloper Force
As your org grows, the relationships between different metadata components become more complex. To understand metadata dependencies, we're happy to introduce the new Dependency API that allows queries for metadata dependencies within the org.
CodeLive with Cynthia Thomas - Refactoring data dependent code.JackGuo20
Cloning data can be harder than it looks; especially if there are multiple records. In this CodeLive session, Cynthia Thomas and Kevin Poorman work to refactor and test code to elegantly clone large numbers of records. Register now to learn about handling collections of data, refactoring, and testing practices.
Curious to know what Lightning Platform is, how you can best develop with it, or looking for specific best practices for implementation? We’ve got the Lightning Platform Product Management team on tap to address some of your most burning questions and help you build apps faster!
Your career, brand, and reputation depend on how well you deliver presentations, both internally and externally. For most people, getting up in front of an audience is a terrifying experience, but it doesn't have to be. By learning a few simple techniques, you can confidently deliver career-boosting technical presentations that won't bore an audience, accidentally tarnish your brand, or limit your career opportunities. Presenting is a craft, not a talent. Those who learn the craft can easily take their careers to the next level.
Have you ever encountered a Salesforce bug? Ever wonder how salesforce.com fixes a bug and how you can track the progress? We invite all admins, developers, partners, and power users to join us on a behind the scenes journey following a bug through salesforce.com support and engineering. Learn how you can use the public known issues site to track bugs affecting your organization.
Increase Customer Adoption with Interactive ContentGavin Austin
Salesforce Case Study: Adding Interactivity to Increase Customer Satisfaction
Presented at the Intelligent Content Conference on how Salesforce built a framework for interactive content, which led to an increase in customer adoption.
Einstein Analytics is the Salesforce-native analytics platform, providing users with insights into their business. This session dives into topics including APIs, metadata, packaging, and other development tools. Whether you’re just getting started or have already been working with Einstein Analytics, join and learn how to best use this analytics suite to build the customer apps people love.
Easy No-Code Integrations with External Services and Visual FlowSalesforce Developers
External Services enables you to integrate apps easier without writing a single line of code, making overall development faster than ever. Gone are the days when you had to write lot of repetitive code to manage the hassles of API Integrations. Join us to see how we can use the power of Visual Workflow and External Services to build apps even faster than ever!
Workshop on how to create successful content strategies with interactive content, structured authoring, and Agile development environments. Delivered at TC Camp 2016.
How Writers Can Benefit from Social SoftwareGavin Austin
Presentation on how writers can increase their business value by using collaboration applications, such as Chatter or Yammer. Delivered at at WritersUA, STC Summit 2014, and STC Web Seminars.
What does the 4th industrial revolution and Artificial Intelligence mean for you? Admins have an amazing opportunity to take advantage of Einstein to bring AI to their companies. Learn how to use the latest features of Salesforce Einstein to embed intelligence to your custom applications built on the Salesforce Platform. We'll also give a sneak peek at the Einstein capabilities planned for the upcoming Spring ‘18 release.
Curious about Einstein Platform Services, and how to use them to build AI-powered apps? Join us for this exclusive, interactive webinar where you can ask product owners, Michael Machado and Zineb Laraki, anything you want! We’ll also have your favorite green wigged evangelist, René Winkelmeyer, on hand to answer any burning questions - don’t miss out! We might even have some roadmap hints :)
In this exclusive webinar, you'll learn about
What’s coming next
What we’re most excited about
How to become an AI expert in no time
How to get started today on some amazing applications
Doc is Dead! How Walkthroughs Changed Salesforce's Content StrategyGavin Austin
A case study on why the Documentation and User Assistance team at Salesforce changed its content strategy to include more forms of interactive content.
Salesforce Labs - Hidden Gems on the AppExchangeSamuel Moyson
Tracking the trailheads your users are doing.
Doing agile project management in Salesforce.
Organizing surveys with your customers in Salesforce.
Did you know all of this is possible without doing any developments?
Even better it's all available for you as apps or Lightning components in the AppExchange.
All this exciting stuff is created by Salesforce Labs.
In this session I want to show you some awesome stuff in the AppExchange made by Salesforce Labs.
In this session I'll cover
-CMTD Enhanced Related List
-Lightning Sharing
-Who's Viewing My Record
-I'm Out! The Out of Office Case Handler
The AppExchange is full of apps and components that you can install in your Salesforce org to add specific functionality. Join us to learn how to create a strategy for using the AppExchange that will make you look like a rockstar and add real value for your company.
This infographic covers the benefits of exercise during pregnancy, including trimester-specific exercises, with advice on how to perform techniques correctly.
Find out more at: https://www.hfe.co.uk/
Have you ever encountered a Salesforce bug? Ever wonder how salesforce.com fixes a bug and how you can track the progress? We invite all admins, developers, partners, and power users to join us on a behind the scenes journey following a bug through salesforce.com support and engineering. Learn how you can use the public known issues site to track bugs affecting your organization.
Increase Customer Adoption with Interactive ContentGavin Austin
Salesforce Case Study: Adding Interactivity to Increase Customer Satisfaction
Presented at the Intelligent Content Conference on how Salesforce built a framework for interactive content, which led to an increase in customer adoption.
Einstein Analytics is the Salesforce-native analytics platform, providing users with insights into their business. This session dives into topics including APIs, metadata, packaging, and other development tools. Whether you’re just getting started or have already been working with Einstein Analytics, join and learn how to best use this analytics suite to build the customer apps people love.
Easy No-Code Integrations with External Services and Visual FlowSalesforce Developers
External Services enables you to integrate apps easier without writing a single line of code, making overall development faster than ever. Gone are the days when you had to write lot of repetitive code to manage the hassles of API Integrations. Join us to see how we can use the power of Visual Workflow and External Services to build apps even faster than ever!
Workshop on how to create successful content strategies with interactive content, structured authoring, and Agile development environments. Delivered at TC Camp 2016.
How Writers Can Benefit from Social SoftwareGavin Austin
Presentation on how writers can increase their business value by using collaboration applications, such as Chatter or Yammer. Delivered at at WritersUA, STC Summit 2014, and STC Web Seminars.
What does the 4th industrial revolution and Artificial Intelligence mean for you? Admins have an amazing opportunity to take advantage of Einstein to bring AI to their companies. Learn how to use the latest features of Salesforce Einstein to embed intelligence to your custom applications built on the Salesforce Platform. We'll also give a sneak peek at the Einstein capabilities planned for the upcoming Spring ‘18 release.
Curious about Einstein Platform Services, and how to use them to build AI-powered apps? Join us for this exclusive, interactive webinar where you can ask product owners, Michael Machado and Zineb Laraki, anything you want! We’ll also have your favorite green wigged evangelist, René Winkelmeyer, on hand to answer any burning questions - don’t miss out! We might even have some roadmap hints :)
In this exclusive webinar, you'll learn about
What’s coming next
What we’re most excited about
How to become an AI expert in no time
How to get started today on some amazing applications
Doc is Dead! How Walkthroughs Changed Salesforce's Content StrategyGavin Austin
A case study on why the Documentation and User Assistance team at Salesforce changed its content strategy to include more forms of interactive content.
Salesforce Labs - Hidden Gems on the AppExchangeSamuel Moyson
Tracking the trailheads your users are doing.
Doing agile project management in Salesforce.
Organizing surveys with your customers in Salesforce.
Did you know all of this is possible without doing any developments?
Even better it's all available for you as apps or Lightning components in the AppExchange.
All this exciting stuff is created by Salesforce Labs.
In this session I want to show you some awesome stuff in the AppExchange made by Salesforce Labs.
In this session I'll cover
-CMTD Enhanced Related List
-Lightning Sharing
-Who's Viewing My Record
-I'm Out! The Out of Office Case Handler
The AppExchange is full of apps and components that you can install in your Salesforce org to add specific functionality. Join us to learn how to create a strategy for using the AppExchange that will make you look like a rockstar and add real value for your company.
This infographic covers the benefits of exercise during pregnancy, including trimester-specific exercises, with advice on how to perform techniques correctly.
Find out more at: https://www.hfe.co.uk/
I have prepared a presentation on "Creating enabling environment for increasing government revenue and private sector investment in Nepal for economic growth and development" which is based on my past experience and current learning from Financing for Development. This presentation targets to the government officials engaged in the policy level and operational level, development professionals and political leaders. This course has enabled my knowledge on private sector involvement, making enabling environment, increasing public revenues and involving more people in to the development need of the settlement, village, town, region, nation and the world.
Watter®: safe, sustainable disinfection for the hatchery sectorHenry Arts
Patented Nontox Electrical Chemical
Activation (ECA) combines salt and
electricity with water, to produce a
powerful, highly sustainable and non-toxic disinfectant that neutralises bacteria, fungi and viruses in accordance with key EN standards for disinfection.
Nontox is available exclusively from
Pas Reform in the hatchery sector.
3BD/3BA 2-story traditional in Mar Vista w/new Brazilian cherry wood floors, large dining area and family room, kitchen w/custom cabinetry, FA/ht, separate laundry, custom shutters & crown moldings. Garage converted to 4th bed/guest or office w/no permit. Desirable deep lot.
"We'll need an Apex trigger to do that." Sound familiar? Take your advanced Admin skills to the next level by developing Apex triggers to solve complex business requirements that can't be implemented using just the configuration-driven features of Force.com. Join us to learn when and how to write your first Apex trigger, and some best practices for making them effective.
You've got your salesforce.com org humming. You are the master of button-click admins. Join us to learn how you can leverage the power of the Force.com platform to build your own social enterprise. At the end of this session, you will walk away with five developer tips and tricks, all possible directly via the browser, that you can put into practice as soon as you get back to the office.
Make testing easier and more productive by applying test-driven development strategies to the world of iOS and Objective-C. Join us to learn about the tools that are available, and hear strategies for writing more testable code and robust tests. You'll be ready to take the next step and integrate these strategies into your daily workflow.
Did you know that the platform has the capability to debug live sessions in sandbox? In this session, you will learn how to set a breakpoint in Apex code and step through a transaction in the Force.com IDE. You will learn how this capability augments Apex debug logs and Apex unit tests, and when to use it.
The AppExchange Marketplace is one of the major ways for customers to learn about your app and how it can benefit them. It is a key element that needs to be in your business’ marketing strategy and building a high-performing listing is a key competitive differentiator. Join us in this session to learn how to build an optimized AppExchange listing and deliver a great custome experience.
Df14 Building Machine Learning Systems with Apexpbattisson
Slide deck from the Dreamforce 20134 talk "Building Machine Learning Systems with Apex". Includes links to github code repository and contact details for speakers.
"We'll need an Apex trigger to do that." Sound familiar? Take your advanced Admin skills to the next level by developing Apex triggers to solve complex business requirements that can't be implemented using just the configuration-driven features of Force.com. Join us to learn when and how to write your first Apex trigger, and some best practices for making them effective.
Join us as we demonstrate how to take advantage of the latest, just announced platform features in your mobile apps using Heroku and Force.com together. We will be talking through use cases, as well as walking through the code you need to know for your own development.
Force.com is designed to let you rapidly build custom applications for the cloud via configuration-driven development, and programmatic logic with Apex and Visualforce. With Force.com, you can design open, mobile, social, and real-time apps in the cloud five times faster than traditional software development approaches. Join us for an overview of the Force.com Platform, and learn how to get started building your first app in the cloud.
The Ideal Salesforce Development LifecycleJoshua Hoskins
It's common for organizations of all sizes to stumble a bit before adopting an effective Release Management strategy. Whether you are small or large, join us as we cover important best practices, like: How many Sandboxes and what kind do I need? How can Developers and Admins best compliment each other's efforts? What is the best way to promote changes from one environment to another? Why can't I do my development in Prod? Get actionable recommendations for making your Salesforce development team more customer-focused by making your release cycle cleaner and more efficient.
Audio: https://www.youtube.com/watch?v=SGiBNMahr6g
Are you a Salesforce Admin struggling to find a voice in your company and a seat at the table? Trust and Value are essential assets you can leverage to help you get that YES when proposing new features, attending an event or even getting that raise you know you deserve! Join me to learn three highly effective strategies that will help you earn Trust and prove your Value as an administrator.
Gesture Controlled Interactions with Platform Events and IoT ExplorerSalesforce Developers
Learn how to leverage gesture sensors, Platform Events and IoT explorer to interact with Salesforce data and even navigate the Lightning Experience UI.
The Force.com platform was written to optimize multi tenant resources. Your code should be, too. In this session you will learn why it is important to bulkify your code and see concrete examples of best practices. This will include the use of custom settings, optimization with maps, and how to avoid breaching governor limits.
Join us as we show you how to develop advanced, interactive tables and charts in Visualforce using a combination of jQuery and JavaScript Remoting. Learn how to quickly turn a simple HTML table into a sortable and filterable table with pagination, and how to build an interactive chart to display complex relationships.
Connecting with the enterprise - The how and why of connecting to Enterprise ...Kevin Poorman
Not everyone plays games; fewer games really take off. But we all use email, we all have systems that we login to just for work. These Enterprise systems are part of a large and ever-growing category of spending for IT Managers. But Enterprise systems ... stink. RubyMotion developers are in a unique position to integrate with these Enterprise Software systems while providing beautiful, functional and elegant interfaces. Join in as we learn why we should be writing Enterprise connected apps, and walk through an example of connecting to Salesforce using their iOS SDK.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
4. Safe Harbor
Safe harbor statement under the Private Securities Litigation ReformAct 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 andcustomer 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 resultsand 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 resultsof 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 thatare currently available.
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
15. #6 Thou shalt have a happy balance
between clicks & code
– “I get an error saying that I’ve reached the maximum number of workflows”
– Triggers that replicate declarative functionality.
• Roll-up summary
• Workflows
• Flow Triggers
Good Salesforce Architectural Design
17. #8 Thou shalt make use of relationships to reduce
queries wherever possible
18. #9 Thou shalt aim for 100% test coverage
In general test your methods for:
Positive effects.
• Given proper input it should act like this.
• Not just happy path, but all logic branches.
Negative effects.
• Given bad data it should error like this.
Role/Profile/User effects
Given a user with X profile and Y role it should act like this.
Bulkification
• Load 200 or more records to test limits.
19. #10 Thou shalt write meaningful and useful tests
• Not a test without System.assert calls
• System.assert(A==B)
• System.AssertEquals(A,B)
• System.AssertNotEquals(A,B)
• The more assertions the better.
• Create mock data, never rely on existing production data.
• Test all conditions, not just positive test cases
• Test one criteria per unit test.
20.
21.
22.
23. #Bonus! Thou shalt feel free to break these as
wisdom merits.
After all:
Sometimes you just need a list of Id’s
These commandments, despite their name, are guidelines for success,
not syntactical rules you just can’t break.
Break them if you need to, Adhere if you can – they’ll save you time in
the long run.
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.
DEMO:
Showing developer console
Executing code and showing error
List<Account> accLst = new List<Account>([SELECT Id, Name FROM Account LIMIT 100]);
for (Account acc : accLst){
Integer numWithEmail = 0;
List<Contact> contactLst = new List<Contact>([SELECT Id, Email FROM Contact WHERE AccountId = :acc.Id]);
for (Contact cont : contactLst){
if (Cont.Email != null){
numWithEmail++;
}
}
System.debug(acc.Name+' has '+numWithEmail+' contacts with emails');
}
Make sure log levels are:
DB: Info
Callouts : Error
Apex Code: Debug
Validation: Error
Workflow: Error
Profilng: Debug
Visualforce: Error
System: Error
DEMO:
Change code in developer console.
Show debug log with now a query limit of 1.
List<Account> accLst = new List<Account>([SELECT
Id,
Name,
(SELECT Id, Email FROM Contacts)
FROM
Account
LIMIT 100]);
for (Account acc : accLst){
Integer numWithEmail = 0;
for (Contact cont : acc.Contacts){
if (Cont.Email != null){
numWithEmail++;
}
}
System.debug(acc.Name+' has '+numWithEmail+' contacts with emails');
}
DEMO:
Showing developer console
Executing code and showing error
List<Account> accLst = new List<Account>([SELECT Id, Name FROM Account LIMIT 100]);
for (Account acc : accLst){
Integer numWithEmail = 0;
List<Contact> contactLst = new List<Contact>([SELECT Id, Email FROM Contact WHERE AccountId = :acc.Id]);
for (Contact cont : contactLst){
if (Cont.Email != null){
numWithEmail++;
}
}
System.debug(acc.Name+' has '+numWithEmail+' contacts with emails');
}
Make sure log levels are:
DB: Info
Callouts : Error
Apex Code: Debug
Validation: Error
Workflow: Error
Profilng: Debug
Visualforce: Error
System: Error
DEMO:
Change code in developer console.
Show debug log with now a query limit of 1.
List<Account> accLst = new List<Account>([SELECT
Id,
Name,
(SELECT Id, Email FROM Contacts)
FROM
Account
LIMIT 100]);
for (Account acc : accLst){
Integer numWithEmail = 0;
for (Contact cont : acc.Contacts){
if (Cont.Email != null){
numWithEmail++;
}
}
System.debug(acc.Name+' has '+numWithEmail+' contacts with emails');
}
DEMO:
Showing developer console
Executing code and showing error
List<Account> accLst = new List<Account>([SELECT
Id,
Name,
Contacts_with_Email_Address__c,
(SELECT Id, Email FROM Contacts)
FROM
Account
LIMIT
151]);
for (Account acc : accLst){
Integer numWithEmail = 0;
for (Contact cont : acc.Contacts){
if (Cont.Email != null){
numWithEmail++;
}
}
System.debug(acc.Name+' has '+numWithEmail+' contacts with emails');
acc.Contacts_with_Email_Address__c = numWithEmail;
update acc;
}
List<Account> accLst = new List<Account>([SELECT
Id,
Name,
Contacts_with_Email_Address__c,
(SELECT Id, Email FROM Contacts)
FROM
Account
LIMIT
151]);
List<Account> accToUpd = new List<Account>();
for (Account acc : accLst){
Integer numWithEmail = 0;
for (Contact cont : acc.Contacts){
if (Cont.Email != null){
numWithEmail++;
}
}
System.debug(acc.Name+' has '+numWithEmail+' contacts with emails');
if (acc.Contacts_with_Email_Address__c <> numWithEmail){
acc.Contacts_with_Email_Address__c = numWithEmail;
accToUpd.add(acc);
}
}
update accToUpd;
Declarative crazy. 500+ fields on an object, loads of workflows – It can get really hard to see what’s going on in the same way bad coding can be hard.
When querying for a collection of records, you can query into either a list or a map. By default it seems we all learn to query into a list, like we see there in the first block of code.
In complex logic situations the ability to pull from the collection a specific record, by it’s id is essential.
In refactoring situations it’s easy to convert your list to a map (line 10)
Queries are limited.
Use your queries wisely, and remember to query UP.
Start with the childmost object and reference parent objects through the relationship __r fields
Positive Test cases should check for expected results not only of the unit overall but of logic branches.
As a consultant, I often inherit orgs that, at first glance contain great test coverage.
Just because it gives you code coverage results doesn’t mean it’s a test
But on deeper inspection I realize that the test methods simply execute the code in question.
Just executing your code within a Test class, doesn’t do anything to prove that your code works.
Use the System.assert(), System.AssertEquals() and System.AssertNotEquals() methods
You can assert Record Counts, object properties, in fact you should assert the