Add Opportunity Record with C# RRS feed

  • Question

  • I am trying to Create an Opportunity record from C# for CRM 2011. This is the code I am using:
    Entity opportunity = new Entity("opportunity");
        opportunity["new_source"] = p.LeadOriginDetail;
        opportunity["opportunityratingcode"] = new OptionSetValue(3);
        opportunity["new_leadstatus"] = new OptionSetValue(100000000);
        opportunity["statuscode"] = p.Type;
        opportunity["ownerid"] = "Lead Share";
        Guid opportunityId = orgService.Create(opportunity);

    I keep getting this error "Customer not specified." How do you add Opportunity records. The same code works for adding records to Accounts.
    Friday, October 7, 2011 8:48 PM


  • Solved it.


    Added: opportunity["customerid"] = new EntityReference("account", accountId);

    • Marked as answer by CrazyeD1583 Friday, October 7, 2011 9:08 PM
    Friday, October 7, 2011 9:08 PM