-
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
Fixing Customer Follow-Up Delays Using Salesforce Sales Cloud Automation
Customer follow-up delays continue to be a major issue for sales teams. A recent industry study reported that 48% of sales opportunities fail due to…
Certified Salesforce Consulting Partner – A Game Changer for Businesses
In today’s digital world, businesses rely on Customer Relationship Management (CRM) platforms like Salesforce to streamline operations, enhance customer engagement, and drive sales growth. However,…
Step by Step Procedure to Implement reCAPTCHA with Visualforce Page
Introduction Salesforce web apps are developed and used from a long time through Visualforce platform. These apps can provide better functionality and performance, but at…
Popular Salesforce Videos
Is Salesforce A Good Career In 2022?
Wondering whether Salesforce is a good career or not? Still have some doubts about it. Watch this video and join this useful group for Salesforce…
How To Land A Salesforce Job In India
This video explained about to land a Salesforce job in India. This is a great opportunity to enter the Salesforce echo systems for non-Salesforce professionals…
Salesforce Connect ( Cross-Org Adaptor ) | Salesforce Tutorial
This video will talk about external objects using Salesforce Connect, also known as Cross-Org Adaptor. 00:00 Introduction 00:29 Introduction to Cross Org Adapter 01:51 Create…