function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
trigger oneActivityMandatory on Opportunity (before update){ set<id> oppId=new set<id>(); map<id,id> mapActivityOpp= new map<id,id>(); List<ActivityHistory>lstActivity =new List<ActivityHistory>(); for(opportunity each:Trigger.New){ if(each.Trigger.Oldmap.get(each.stage)=='Preprosepect' && each.stage!='Preprosepect'){ oppId.add(each.id); } } lstActivity =[SELECT id,name,whoId FROM ActivityHistory WHERE whoId IN:oppId]; for(ActivityHistory each:lstActivity){ mapActivityOpp.put(each.WhoId,id); } for(opportunity eachOpp:Trigger.New){ IF(mapActivityOpp.get(eachOpp)==null){ eachOpp.addError('Atleast one Activity mandatory'); } } }
You want to put validation in your opprotunity level. Please try this code please let me know if this will help.
Thanks,
Keyur Modi