You need to sign in to do that
Don't have an account?
shrayas reddy
custom error message not being displayed. I am getting error when required but the custom error message is not being displayed
trigger parentAccounttrigger on Account (before insert) {
parentAccount.parent(trigger.new);
}
--***--
public class parentAccount {
public static void parent(List<account> acc){
Set<Id> Ids = new Set<Id>();
List<Account> acct = new List<Account>();
for(account a:acc){
if(a.ParentId != null){
Ids.add(a.ParentId);
}
}
acct = [SELECT Name, Id,ParentId FROM Account WHERE Id=:Ids];
for(Account ac:acct){
if(ac.ParentId != null){
// the below custom mssage is not being displayed
ac.addError('There is already a parent for your parent account');
}
}
}
}
parentAccount.parent(trigger.new);
}
--***--
public class parentAccount {
public static void parent(List<account> acc){
Set<Id> Ids = new Set<Id>();
List<Account> acct = new List<Account>();
for(account a:acc){
if(a.ParentId != null){
Ids.add(a.ParentId);
}
}
acct = [SELECT Name, Id,ParentId FROM Account WHERE Id=:Ids];
for(Account ac:acct){
if(ac.ParentId != null){
// the below custom mssage is not being displayed
ac.addError('There is already a parent for your parent account');
}
}
}
}
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
Try Below Code Please Close Your By Marking It As Best Answer If It Helps So It Also Helps Others In Future
Thank You!