trigger accName on Account (before insert, before update) { List acc;
if (Trigger.isBefore) { if (Trigger.isInsert) {
for(Account a:Trigger.New) { if(a.Administrative_Office__c == True) { a.Name = a.Name + ' ( A ) ' ; } else if(a.Data_Center__c == True) { a.Name = a.Name + ' ( D ) ' ; } else { if (Trigger.isUpdate) { List accn = new List(); accn = [SELECT Id,Name FROM Account WHERE Id IN: Trigger.oldMap.keySet() LIMIT 1];
trigger accName on Account (before insert, before update) {
List<Account> acc;
if (Trigger.isBefore) {
if (Trigger.isInsert) {
for(Account a:Trigger.New) {
if(a.Administrative_Office__c == True) {
a.Name = a.Name + ' ( A ) ' ;
}
else if(a.Data_Center__c == True) {
a.Name = a.Name + ' ( D ) ' ;
}
else {
if (Trigger.isUpdate) {
List<Account> accn = new List<Account>();
accn = [SELECT Id, Name
FROM Account
WHERE Id IN: Trigger.oldMap.keySet()
LIMIT 1];
for (Account au : accn) {
if(au.Administrative_Office__c == True)
{
au.Name = au.Name + ' ( A ) ' ;
}
else if(au.Data_Center__c == True)
{
au.Name = au.Name + ' ( D ) ' ;
// au.Name = au.Name;
}
update accn;
}
}
}
insert a;
}
}
}
}
update accn;
}
}
}
insert a;
}
} } }