-
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

How Businesses Can Take Benefits of Salesforce to Improve Marketing Efforts?
Salesforce is the world’s number one CRM provider with an illustrious range of products. One of the most important products among all is Salesforce Marketing…

Leverage Salesforce for Building Client Relations
CRM facilitates businesses to build a relationship with their customers that, in turn, generates allegiance and customer engagement. Since customer loyalty and revenue are both…

Twilio Integration With Salesforce Part I - How to Send A Message From Salesforce to a Phone Number
This blog is the first part of Two part blog on Integrating your Twilio Account with Salesforce. In this blog, I will be displaying how…
Popular Salesforce Videos
Demo - Increase Your Sales Effectiveness With Sales Enablement and eSigning Inside Salesforce
In this video you will learn how to increase your sales effectiveness by creating, sending, tracking and engaging your potential customer, right inside Salesforce, through…
Salesforce Chatter Tutorial | Chatter Overview And Demo | Chatter In Salesforce
This Salesforce Chatter Tutorial will give an overview of Chatter which includes enabling chatter, configuring chatter groups and creating customer groups. Salesforce Chatter will be…
All Things Telesales Podcast
Sales Director at Natterbox, Ian Moyse shares with us 3 Powerful Pillars of Servant Leadership - Yearning, Earning, Learning. Ian drops wisdom bombs left and right…