2016-04-27 47 views
0

餘米試圖動態CRM 2015集成了這個帖子,Integration to Microsoft Dynamic CRM 2011的幫助下,我寫了這個代碼:Dynamics CRM中2015年:值不能爲空 r n參數名:詳細

Dictionary<string, string> parameters = GetCustomParameters(company.Id); 
Uri uri = new Uri(parameters["serviceUrl"]); 
var username = parameters["username"]; 
var password = parameters["password"]; 
var entity = parameters["entity"]; 
ClientCredentials credentials = new ClientCredentials(); 
credentials.UserName.UserName = username; 
credentials.UserName.Password = password; 

OrganizationServiceProxy osproxy = new OrganizationServiceProxy(uri, null, credentials, null); 
IOrganizationService _services = (IOrganizationService)osproxy; 
QueryExpression query = new QueryExpression() 
{ 
    EntityName = entity, 
    ColumnSet = new ColumnSet("firstname", "lastname", "emailaddress") 
}; 

EntityCollection retrieved = _services.RetrieveMultiple(query); 

當我執行此,它會提示:

值不能爲空\ r \ n參數名:詳細

任何幫助,將不勝感激。我沒有任何以前的CRM整合經驗。

+0

不知道這一點錯誤,但嘗試使用[CrmConnection](https://msdn.microsoft.com/ en-us/library/gg695810(v = crm.7).aspx)來代替連接。 – Polshgiant

回答

0

這QueryExpression測試是由像CRM工作2016

這是一個例子

ConditionExpression condicion1 = new ConditionExpression(); 
      condicion1.AttributeName = "name"; 
      condicion1.Operator = ConditionOperator.NotNull; 

      FilterExpression filtro = new FilterExpression(); 
      filtro.Conditions.Add(condicion1); 
      filtro.FilterOperator = LogicalOperator.And; 

      QueryExpression consulta = new QueryExpression("account"); 
      consulta.Criteria.AddFilter(filtro); 
      consulta.ColumnSet = new ColumnSet("name", "telephone1"); 

      EntityCollection resultados = service.RetrieveMultiple(consulta); 

      foreach (Entity c in resultados.Entities) 
      { 
       Console.WriteLine("{0} | {1}", c["name"].ToString(), c["telephone1"].ToString()); 
      } 
      Console.Read(); 
相關問題