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 closedopportunity on Opportunity (before update) { map<id,opportunity> oppymap= new map<id,opportunity>(); for(opportunity opp:Trigger.new){ if(opp.StageName=='Closed Won'){ oppymap.put(opp.id, opp); } } if(!oppymap.isEmpty()){ integer count = [SELECT count() FROM OpportunityLineItem WHERE opportunityid IN:oppymap.keySet() ] ; for(opportunity opp1:Trigger.new){ if(count==0){ opp1.adderror('atleast one product'); } } } }
Can you try the below apex trigger on opporutnity.
If this solution helps, Please mark it as best answer.
Thanks,
Try Below Trigger Please Mark It As Best Asnwer If It Helps
Thank You!