-
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
Build A Strong and Powerful Community and Go Beyond Your Dreams
Over the last few weeks, we had relished bringing out the outstanding features of Sales Cloud and Service Cloud that will be released in Spring ‘20. Sales, Service, and…
AppExchange vs Custom Development: Making a Conscious Choice in Salesforce
Salesforce is an evolving CRM. It rolls out new features and updates in its annual releases, for various Salesforce packages. Like Salesforce, business requirements and…
Popular Salesforce Videos
Leads & Opportunities for Lightning Experience - Create and Convert Leads
Learning Objectives After completing this unit, you’ll be able to: Update a record’s stage or status using Path. Update records in the Kanban view. Use…
Marketing Automation with Salesforce Journey Builder
Marketing Automation which is future of marketing can be simply understood as automating your marketing communication programs. we are going to talk about Salesforce Journey…
Is the Salesforce Marketing Cloud the Future For Business?
As the market changes, one needs to keep up with the times. Companies are interested in Salesforce Marketing Cloud because it gives them a competitive…