-
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 Dean Infotech's Automated CSAT Surveys Enable Business Growth?
Ever noticed how some companies consistently deliver outstanding customer experiences? From the customer’s side, it seems effortless — but behind the scenes, maintaining that across…
Insider Tips for an Easy Migration into Salesforce
As the owner of a growing nonprofit enterprise, you need to find the right tools to ensure that your company can quickly adapt to its…
Enhance Your Single View of The Customer Using Salesforce Marketing Cloud Connect
Many of our Salesforce Marketing Cloud customers use Marketing Cloud as a standalone product, however, it is simple to connect Marketing Cloud with the Sales,…
Popular Salesforce Videos
Gantt Charts in Salesforce Lightning | Salesforce Tutorials
In this video, you will learn to implement the Gantt Chart in your Salesforce org. We will use Google Gantt Chart scripts and we will…
myTrailhead Product Filters | Salesforce Tutorial Video
Salesforce myTrailhead has now released their next update in product filters. You can now create your own product filters that are relevant to your business…
Salesforce Einstein Top FAQs'
We hear a lot of questions from people regarding Salesforce Einstein which is why we've answered them below. So that you have complete and top…