2015-02-10 70 views
0

我試圖檢索與機會,這statecode不等於1試過QueryByAttribute,QueryExpression和RetrieveMultipleRequest,但仍沒有解決方案的所有電話。
這裏是一些代碼,我寫的。檢索CRM 4個實體與自定義工作流活動的C#自定義字段

 IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService)); 
     IWorkflowContext context = contextService.Context; 
     ICrmService crmService = context.CreateCrmService(true); 
     if (crmService != null) 
     { 
      QueryByAttribute query = new Microsoft.Crm.Sdk.Query.QueryByAttribute(); 
      query.ColumnSet = new Microsoft.Crm.Sdk.Query.AllColumns(); 
      query.EntityName = EntityName.phonecall.ToString(); 
      query.Attributes = new string[] { "regardingobjectid" }; 
      query.Values = new string[] { context.PrimaryEntityId.ToString() }; 
      RetrieveMultipleRequest retrieve = new RetrieveMultipleRequest(); 
      retrieve.Query = query; 
      retrieve.ReturnDynamicEntities = true; 
      RetrieveMultipleResponse retrieved = (RetrieveMultipleResponse)crmService.Execute(retrieve); 
     } 
     return ActivityExecutionStatus.Closed; 
    } 

而對於QueryExpression

QueryExpression phCallsQuery = new QueryExpression(); 
ColumnSet cols = new ColumnSet(new string[] { "activityid", "regardingobjectid" }); 
phCallsQuery.EntityName = EntityName.phonecall.ToString(); 
phCallsQuery.ColumnSet = cols; 
phCallsQuery.Criteria = new FilterExpression(); 
phCallsQuery.Criteria.FilterOperator = LogicalOperator.And; 
phCallsQuery.Criteria.AddCondition("statuscode", ConditionOperator.NotEqual, "1"); 
phCallsQuery.Criteria.AddCondition("regardingobjectid", ConditionOperator.Equal, context.PrimaryEntityId.ToString(); 

幾乎相同,我總是得到這樣的SOAP異常或「服務器無法繼續請求」調試時。

回答

0

爲了得到異常的詳細嘗試使用下面的代碼:

RetrieveMultipleResponse檢索= NULL;

try 
{ 
    retrieved = (RetrieveMultipleResponse)crmService.Execute(retrieve); 
} 
catch(SoapException se) 
{ 
    throw new Exception(se.Detail.InnerXml); 
} 
相關問題