-
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
User Management and Object-level Security in Salesforce
In Salesforce, every user is at a time found with a profile, username, and password. Along with other settings, the outline decides which move a…
How To Lock Records In Salesforce | The Complete Guide
The client shouldn't have the option to edit the field values of the record. Salesforce will try up to 10 times to obtain a record…
Why Everyone Should Integrate SharePoint with Salesforce
SharePoint is one of the most popular document management platforms today. It is used by virtually all major enterprises since it ties in neatly with…
Popular Salesforce Videos
What benefits Salesforce Email integration provides for my business?
This video puts light on the benefits of Salesforce Email Integration for Business. Every aspect of Email Integration is provided and discussed in detail along…
Create Custom Object, Tabs and ListView in lightning, Salesforce
In this video, DeveloperTrix explains how you can create custom objects, custom object tabs, and list views in the Salesforce platform. He also covers how…