-
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
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…
An Introduction To Salesforce Flow Basics
The Power of Automation Over time, most companies set up a set of practices that can meet different business needs. These methods are usually unique…
Approval Process on Opportunity Product in Salesforce
An Approval Process is an automated process an organization can use to approve records in Salesforce. It specifies the steps which are necessary for a…
Popular Salesforce Videos
5 Steps to Faster Case Resolution | Salesforce Support
When it comes to filling out a Salesforce case from, the description field and attached files are key to fast routing and resolution. Here are…
Automate Workflows and Process Intelligence with Nintex Development Services | Salesforce
Nintex is a leading process improvement, workflow, and automation software platform. In their own words, you can use the Nintex platform to manage, automate, and…
How to Find the Job ID for a Test Send and Send Flow | Salesforce
This video will help you understand how to find the job id for a Send Flow and for a Test Send. 00:00 - Introduction 00:30…