-
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
Does Salesforce CPQ have the Power to Streamline your Sales Process? | Salesforce CPQ
One day someone asked me "why Salesforce CPQ is better than customizing Salesforce Sales Cloud for Streamlining my Sales Process?". Salesforce says that Salesforce CPQ is…
ChannelOnline To Salesforce Integration Setup [EPISODE -2]
Integration Setup In Salesforce Resellers must perform the following setup steps in Salesforce in order to exchange data Enable the correct employee for use with…
Popular Salesforce Videos
Introduction to Salesforce Einstein OCR
In this session, we will learn about Einstein OCR and Create/Update Leads and Contacts using Business Cards. Let’s welcome an amazing #Summer20 release gem –…
Salesforce Online Training Videos For Beginners | Campaign Management
Learn all about the Salesforce campaign management in this video. Watch and learn. If you have any doubts or questions, please let us know in…
How to Create a Jira Ticket from Salesforce?
Learn how to create a Jira ticket in Salesforce using two different methods and how to choose a Jira project. Know more at https://www.sinergify.com/