-
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
Interview Question Part – 3
1. What is an Apex class in Salesforce? An Apex class in Salesforce is a blueprint or template for creating custom business logic and functionality.…
Power Apps: Build Custom Apps without Coding
In today’s fast-paced business world, companies need to adapt quickly to changing demands. One of the biggest challenges organizations face is the ability to develop…
How to Choose The Best Healthcare CRM?
With the rise of consumerism, there is a competitive increase in the healthcare market. Patients have a lot of choices when it comes to picking…
Popular Salesforce Videos
Salesforce Essentials
Watch this video to learn what customer relationship management (CRM) is and how CRM helps companies better engage with prospects and customers, streamline communications, and…
ampus Plus: Salesforce Grants Management System (GMS) Testimonial | TechForce Services
Hear from Campus Plus on their game-changing Grants Management System (GMS) built on Salesforce by TechForce Services! They replaced spreadsheets and siloed forms with a…
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.…