-
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
Relationships in Salesforce Financial Services Cloud
Relationships. One might think that building a good relationship with Salesforce’s Financial Services Cloud would be harder than maintaining a personal relationship, but that is…
Salesforce Slack Acquisition – 5 Reasons Why This Merger is the Best Thing Since Sliced Bread!
Salesforce is bringing in a huge wave of features and services for its users this year. Before the end of 2020, Salesforce signed a $27.7 billion megadeal to…
The Sales Cloud: All You Need to Know
Unleashing Growth with Salesforce Sales Cloud: Revolutionizing Customer Engagement In the digital age, where customers are more empowered and discerning than ever before, businesses must…
Popular Salesforce Videos
Salesforce Interface Sends a Command With Parameters to UiPath Assistant Using JavaScript
Salesforce interface sends a command with parameters to UiPath Assistant using Robotjs Code: https://github.com/cristinegulescu/startUiPathFromSalesforce/blob/master/SalesForceLocal.txt
Customize Salesforce in a Flash with Lightning
This video shows you how to use Lightning App Builder to make page customizations without any code. This enables admins to tailor Lightning Experience for…
Salesforce JavaScript Developer 1 Certification Series
Hi Everyone, SFDC Panther has started the Salesforce JavaScript Certification series and this is the first session. What you will learn: Variables Data Types Operators…