You need to sign in to do that
Don't have an account?
renu anamalla 9
After insert and after update differnce n give simple scenario
After insert and after update differnce n give simple scenario
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
After insert: Trigger will be fired after inserting a record.
After insert
--> is used to insert related object, not the same object.
--> to send notification email.
After Update:
Trigger will be fired after updating a record.
After update
--> is used to update related object, not the same object.
--> to send notification email.
If we want to update a record of same object, we cannot use After trigger, because it causes read only error. This is because, after inserting or updating, we cannot update a record. Update should be made in before event for the same object.
Here is the example for automatically creating Opportunity after creating/updating an Account record.
trigger addRelatedRecord on Account (after insert, after update)
{
List<Opportunity> oppList = new List<Opportunity>();
for ( Account a: [SELECT Id, Name From Account
where id IN : Trigger.new And Id Not In (Select AccountId From Opportunity)])
{
oppList.add(new Opportunity(Name=a.Name + 'Opportunity', StageName='Prospecting', CloseDate= System.today().addMonths(1), AccountId=a.Id));
}
if(oppList.size()>0)
{
insert oppList;
}
}
Please mark it as a best answer if it helps you.
Thank You,
Sohel Mohd