0

i am trying to pass opportunity id in to opportunity lookup in orde bt getting this error. can anyone plz help me.

error-Error: Compile Error: Illegal assignment from Id to Opportunity at line 9 column 16

public class order_Creation
{
    public static void osCreated(List<Opportunity> op)
    {
       List <Order> orderToInsert = new List <Order>(); 
            for(Opportunity o : op){        
         if(o.StageName == 'Closed Won' && o.RecordTypeId == '01228000000EyCa'){      
               Order v = new Order();
               v.Opportunity = o.id;         
               v.Account = o.Account; 
               v.EffectiveDate = System.today();
               v.ContractId = o.Contract_Number__c;
               v.Status = 'Draft'; 
               orderToInsert.add(v);
         }
       }

        insert orderToInsert;


   }

}
1

You need to update

v.Opportunity = o.id;         
v.Account = o.Account; 

to

v.OpportunityId = o.id;         
v.AccountId = o.Account; 

Always you can use workbench to check all the object field API name.

https://workbench.developerforce.com/

1
  • no no that is standard lookup , already ther in order, and that opportunityId should be taken,,, thanks, now its working – RAT__ Feb 5 '16 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.