locked
Create contract with CRM Tooling SDK CRM 2013 RRS feed

  • Question

  • I try to create contracts with the following code

    ...
    Dictionary<string, string> searchParameters = new Dictionary<string, string>();
    CrmServiceClient.LogicalSearchOperator searchOperator = new CrmServiceClient.LogicalSearchOperator();
    Guid contracttemplateid = Guid.Empty;
    Dictionary<string, Dictionary<string, object>> results = _servClient.GetEntityDataBySearchParams("contracttemplate", searchParameters, searchOperator, null);
    if (results != null)
    {
     foreach (Dictionary<string, object> result in results.Values)
     {
      if (result.ContainsKey("contracttemplateid"))
      {
       contracttemplateid = (Guid)result["contracttemplateid"];
      }
     }
    }

    inData = new Dictionary<string, CrmDataTypeWrapper>();

    inData.Add("contracttemplateid", new CrmDataTypeWrapper(contracttemplateid, CrmFieldType.Lookup));
    inData.Add("accountid", new CrmDataTypeWrapper(new Guid("735C889E-0C81-E411-80E7-005056A660B0"), CrmFieldType.Lookup));
    inData.Add("accountidname", new CrmDataTypeWrapper("John", CrmFieldType.String));
    inData.Add("billingcustomerid", new CrmDataTypeWrapper(new Guid("735C889E-0C81-E411-80E7-005056A660B0"), CrmFieldType.Lookup));
    inData.Add("billingcustomeridname", new CrmDataTypeWrapper("John", CrmFieldType.String));
    inData.Add("title", new CrmDataTypeWrapper("Title", CrmFieldType.String));
    ...
    _servClient.CreateNewRecord("contract", inData)
    ...

    I got this exception:

    An unexpected error occurred. => System.NullReferenceException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #A356E9B1

    What`s wrong?

    Tuesday, December 16, 2014 1:12 PM

Answers

  • This is a WPF-Application (not a plugin). Now, I use the

    "Microsoft.Xrm.Client.Services" and everything is ok. I think there are some bugs in the "Microsoft.Xrm.Tooling.Connector" (Spring 2014 update).

    Thursday, December 18, 2014 9:49 AM

All replies

  • From where you are trying to execute this code ? is it a console app / plugin or any thing else?

    Have you tried to place Try Catch blocks and see the inner exception ? Also, Some of the code bits have been missed, you sure that there wasn't any thing wrong in the code that has been masked with "...." ?

    90% of times a simple line by line debug would directly give you where is the problem.

    Regards

    Srikanth


    Imposible it self is having Posible.. Dont leave it until you get it..

    Tuesday, December 16, 2014 10:34 PM
  • Look at _servClient.LastException or turn on tracing (here)

    It should give you details,  I suspect your missing a required field, or you have an incorrect type.

    from your code snip,, your missing
    expireson,TransactionCurrencyId , CustomerId, ContractTemplateAbbreviation , ActiveOn

    Mattb.

    Wednesday, December 17, 2014 10:18 PM
  • This is a WPF-Application (not a plugin). Now, I use the

    "Microsoft.Xrm.Client.Services" and everything is ok. I think there are some bugs in the "Microsoft.Xrm.Tooling.Connector" (Spring 2014 update).

    Thursday, December 18, 2014 9:49 AM
  • When I look at the method specification, I don't see any GetEntityDataBySearchParams() that takes 4 arguments.
    Thursday, December 18, 2014 3:36 PM