-
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
10 Hottest Salesforce Features to Simplify Your Business Tasks
In today’s digital age, businesses must innovate to build strong customer relationships, streamline operations, and drive growth. Salesforce, a leading customer relationship management (CRM) platform,…
Health Cloud Console Unit in Salesforce - Get Started
In this blog, we will discuss about Health Cloud, its specific terminology, and its architecture. Let’s move to Salesforce Health Cloud Core Capabilities which are:…
Comprehensive Guide on Salesforce Web-to-Case
For any organization or business, growth depends on how they provide service(s) to the customer. Getting comprehensive details of customers’ problems is one of the most…
Popular Salesforce Videos
How to Create a Landing Page in Salesforce Account Engagement (Pardot)?
A landing page acts as a customized doorstep for potential clients. It's crucial because it guides their focus toward a particular action, such as signing…
Salesforce CPQ from Scratch
CPQ Salesforce, or Configure, Price, Quote Software by Salesforce is a sales tool for companies to provide accurate pricing with any given product configuration scenario.…