-
Issue with After Trigger And Before Trigger in Salesforce
Hi All,
this trigger is not working
trigger ClosedOpportunityTriggera on Opportunity (before insert,before update) {
List<Task> toBeAddedTasks = new List<Task>();
for(Opportunity A:[SELECT id FROM Opportunity WHERE StageName = 'Closed Won' AND id IN :Trigger.New])
{ toBeAddedTasks.add(new Task(Subject = 'Follow Up Test Task', WhatId = A.Id)); }
upsert toBeAddedTasks; }it is working when i change before insert to after and before update to after
trigger ClosedOpportunityTriggera on Opportunity (after insert,after update) {
List<Task> toBeAddedTasks = new List<Task>();
for(Opportunity A:[SELECT id FROM Opportunity WHERE StageName = 'Closed Won' AND id IN :Trigger.New])
{ toBeAddedTasks.add(new Task(Subject = 'Follow Up Test Task', WhatId = A.Id)); }
upsert toBeAddedTasks; }i need to know why it is not working similar in both scenario
thanks
Log In to reply.
Popular Salesforce Blogs
Why Should You Choose Salesforce Revenue Cloud & CPQ!
Streamline Your Lead to Cash Business Processes in a Single Unified Platform Salesforce Revenue Cloud Suite is part of the Salesforce Customer 360 platform. It is…
What is the Salesforce Guidance Center in 2023? | The Trailhead Guide
The Guidance Center is a one-stop shop for learning and enablement in the flow of work. Learning is both recommended to users automatically by Salesforce…
Popular Salesforce Videos
Salesforce Einstein Activity Capture Guide
Have you ever had issues maintaining accurate, up-to-date information between your Salesforce org and your clients? Einstein Activity Capture is here to work for you…
Salesforce Consultant Certifications - Large Data and Transaction Volumes
As you already aware, expertise in Salesforce is in huge demand. The Salesforce Certifications are industry-recognized and are a proof of your skill/expertise in Salesforce.…
Avoid Common Security Mistakes in Salesforce
Are you using Salesforce in the most secure way? Security is not a “set it and forget it” thing. We conduct Salesforce Security Risk Assessments…