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 OpportunityTriggerForOrder on Opportunity(after insert, after update) { Set<Id> oppIdSet = new Set<Id>(); List<Order> ordList = new List<Order>(); for(Opportunity opp: Trigger.new) { if(opp.AccountId != null) { oppIdSet.add(opp.Id); Order ord = new Order(); ord.OpportunityId = opp.Id; ord.AccountId = opp.AccountId; ord.EffectiveDate = opp.CloseDate; ord.Status= 'Draft'; ord.Pricebook2Id = opp.Pricebook2Id; ordList.add(ord); } } insert ordList; }
Here is a sample code