You need to sign in to do that
Don't have an account?

Need a help on trigger about to Insert and update
Hi All,
Please help to update the trigger for old value, please where i'm doing wrong.
here is the code
trigger BulkifyTri1 on Account (before insert, before update){
set<Id> accIds = new set<Id>();
list<Account> UpdateAcc = new list<Account>();
list<Account> accst = new list<Account>();
list<Account> InsertAcc = new list<Account>();
for ( Account a : trigger.new){
if ( a.AccountNumber != NULL )
a.Type = 'Other';
InsertAcc.add(a);
}
insert InsertAcc;
accst = [select id, name,AccountNumber,Type from account where Id in :accIds];
for(Account ac:accst )
{
if (ac.AccountNumber != NULL ){
ac.Type = 'Prospect';
UpdateAcc.add(ac);
}
}
if(UpdateAcc.size()>0)
{
update UpdateAcc;
}
}
With Regards,
Bheemudu Neeli
Please help to update the trigger for old value, please where i'm doing wrong.
here is the code
trigger BulkifyTri1 on Account (before insert, before update){
set<Id> accIds = new set<Id>();
list<Account> UpdateAcc = new list<Account>();
list<Account> accst = new list<Account>();
list<Account> InsertAcc = new list<Account>();
for ( Account a : trigger.new){
if ( a.AccountNumber != NULL )
a.Type = 'Other';
InsertAcc.add(a);
}
insert InsertAcc;
accst = [select id, name,AccountNumber,Type from account where Id in :accIds];
for(Account ac:accst )
{
if (ac.AccountNumber != NULL ){
ac.Type = 'Prospect';
UpdateAcc.add(ac);
}
}
if(UpdateAcc.size()>0)
{
update UpdateAcc;
}
}
With Regards,
Bheemudu Neeli
write your trigger like that Thanks
i hop it helps you
Please Mark it best answer if it helps you :)
All Answers
in your trigger
accst = [select id, name,AccountNumber,Type from account where Id in :accIds];
this id list is blank :)
add account id to set<Id> accIds = new set<Id>();
Thanks
write your trigger like that Thanks
i hop it helps you
Please Mark it best answer if it helps you :)
Is it work for mass Insert and Update?
can you please help me to make it Bulkify, code is remain same.
Thanks and Regards,
Bheemudu
mark it best answerif it helps you :)