You need to sign in to do that
Don't have an account?
santhosh konathala 17
Hi can anybody resolve this where I did wrong If I insert a new record get inserted into notification object.If I update a record ,a new record is created?Below is my code check it?
Trigger insertNotification on Account(after insert,After update) {
List<Notification__c> member1 = new list<Notification__c>();
for(Account member:Trigger.new)
{
Notification__c memb = new Notification__c();
memb.name=member.name;
member1.add(memb);
}
if(member1.size()>0 &&member1.size()!=null){
insert member1;
}
}
List<Notification__c> member1 = new list<Notification__c>();
for(Account member:Trigger.new)
{
Notification__c memb = new Notification__c();
memb.name=member.name;
member1.add(memb);
}
if(member1.size()>0 &&member1.size()!=null){
insert member1;
}
}
try this code.
thanks.
You added after update in the trigger context that's y a new record is creating every time you edit account.
Thanks.
As you said I deleted After update event in Trigger but once existing record updated It was not updated in Notification object.So could you tell what is the solution for it .
Create a field called account(text) on account.
And then try this code. Let me know if it helps.
If it helps make it as best answer.
Thanks.
A great thanks to you code is working very well.
Could you give any suggestion for this scenario in above code:
Only at the time of changing Account name I want to update a record in Notification object.But problem is ,even If I changed field values in an account a new record is being inserted with the same record name.
For that you have to check old account name and new account name name using oldmap and new map.
I have updated code accordingly.
Please let me know if it works.
Make it as best answer if it helps.
Thanks.