You have create trigger on opportunity object. for(opportunity oy:trigger.new){
if(oy.accountid==''){ List<Opportunity> acc=[select id from Opportunity where accountid=:oy.accountid]; if(acc.isEmpty()) oy.addError('Only i opportunity for one account'); }
You have create trigger on opportunity object.
for(opportunity oy:trigger.new){
if(oy.accountid==''){
List<Opportunity> acc=[select id from Opportunity where accountid=:oy.accountid];
if(acc.isEmpty())
oy.addError('Only i opportunity for one account');
}
}