Creating Opportunity with Silverlight RRS feed

  • Question

  • Hi all,

    I'm trying to just create a simple shell Opportunity so I can further it once I know I can create one.  My issue is that I've been able to create Accounts and Contacts through similar code to the Opportunity.  The problem is the Opportunity throws an error in the EndCreate SOAP call.

    private void btnCreateContact_Click(object sender, RoutedEventArgs e) { // Get IOrganizationService instance IOrganizationService myOrgService = SilverlightUtility.GetSoapService(); Entity myContact = new Entity(); myOpp.LogicalName = "opportunity"; // Create the AttributeCollection myOpp.Attributes = new AttributeCollection(); // Specify Last Name and First Name for the contact to be created KeyValuePair<string, object> oppName = new KeyValuePair<string, object>(); oppName.Key = "name"; oppName.Value = "CreateMe"; myOpp.Attributes.Add(oppName); OrganizationRequest myOrgRequest = new OrganizationRequest(); myOrgRequest.RequestName = "Create"; // call the Create method myOrgService.BeginCreate(myOpp, myCreateHandler, myOrgService); }

    public System.Guid EndCreate(System.IAsyncResult result) { object[] _args = new object[0]; System.Guid _result = ((System.Guid)(base.EndInvoke("Create", _args, result))); return _result; }

    So I've followed the code by attaching the solution to a running instance in CRM and the only issue is that at the line "System.Guid _result = ((System.Guid)(base.EndInvoke("Create", _args, result)));" it gives me a very generic error message; even though the data in the call for opportunity is pretty well identical to the opportunity endInvoke.

    So does anyone know if either I'm missing something? Should use some other method? Or know the reason/solution to why it is giving me an error while attempting to create the record?

    Any help is really appreciated.

    • Edited by Bmckie Friday, September 27, 2013 3:59 PM
    Friday, September 27, 2013 3:51 PM