This is the code I am using:
trigger ParentOppToChild on Opportunity (after update)
{
List <Opportunity> oppQueryResults = new List <Opportunity>([Select ID, (Select ID, Dealership__c From OpportunityLineItems) From Opportunity]);
Map<ID,OpportunityLineItem> accountTolineItems = New Map<ID,OpportunityLineItem>();
for(Opportunity o : oppQueryResults)
{
if(o.StageName = 'Closed Won')
{
for(OpportunityLineItem oli : o.OpportunityLineItems)
{
accountToLineItems.put(oli.Dealership__c, new OpportunityLineItem{oli});
if(accountToLineItems.containsKey(oli.Dealership__c))
{
accountToLineItems.containsKey(oli.Dealership__c).add(oli);
}
else
{
accountToLineItems.put(oli.Dealership__c,New OpportunityLineItem[]{oli});
}
}
}
}
}
And this is the error that I am getting: unexpected token: '{' at line 21
Sorry if this is really obvious but I have changed the code around so many times because of this and I can't seem to find an answer elsewhere.
oli
variable to be the value then you should be doing the following:accountToLineItems.put(oli.Dealership__c, oli);