-
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
Salesforce ERP Integration, a Successful Combination
There are two types of systems whose implementation favors increased efficiency in the business processes of any company, these are: Customer Relationship Management (CRM) systems…
Top 5 Ways Salesforce CDP Solves Customer Data Challenges and Benefits Business Growth
Technology is evolving at a fast pace, and so are the customers. In the present time, the way customers interact with a business is highly…
Related Records Updation with the Help of Salesforce Flow
Hello all, In this blog, we will get to know how to update records using Salesforce flow. For updating the related object records we can…
Popular Salesforce Videos
Algoworks Is Now A Salesforce Summit (Platinum) Partner | Salesforce Consulting Services
It's been just a year since we became Salesforce gold consulting partners. Algoworks has now been recognized as a Salesforce Summit Partner (also known as…
Object Oriented Programming - Salesforce Developer Tutorial
In relation to programming languages, object-oriented means that the code focuses on describing objects. An object can be anything that has unique characteristics, such as…
Strange Requirements | Manual Round Robin ID in Salesforce
In this video, you will learn to create a Manual Round Robin ID using custom Apex in Salesforce. The requirement was to create a Round…