2014-09-19 46 views
0

我在我的代碼收到以下錯誤:接收錯誤在工作流活動代碼

條件屬性「sgfdhr_leavetype.new_employeeleavecalculation」:類型的期望的參數(S)「的System.Guid」但收到「Microsoft.Xrm .Sdk.EntityReference」。

我的代碼是下面:

public int Getleavetype(Entity LeaveManagement, IOrganizationService _orgService, CodeActivityContext Acontext) 
     { 
     QueryExpression GetLeavedetails = new QueryExpression(); 
     GetLeavedetails.EntityName = "sgfdhr_leavetype"; 
     GetLeavedetails.ColumnSet = new ColumnSet("new_type"); 
     GetLeavedetails.ColumnSet = new ColumnSet("new_availabledays"); 
     GetLeavedetails.Criteria.AddCondition("new_type", ConditionOperator.Equal, 1); 
     GetLeavedetails.Criteria.AddCondition("new_employeeleavecalculation", ConditionOperator.Equal,LeaveManagement["new_leavedetails"]); 
      EntityCollection LeaveDetails = _orgService.RetrieveMultiple(GetLeavedetails); 
      return (int)LeaveDetails[0]["new_availabledays"]; 
     } 

我上recieving錯誤 「EntityCollection LeaveDetails = _orgService.RetrieveMultiple(GetLeavedetails);」這行代碼如上。

感謝,

回答

0

的錯誤是很清楚你有這樣的條件:

GetLeavedetails.Criteria.AddCondition("new_employeeleavecalculation", ConditionOperator.Equal, LeaveManagement["new_leavedetails"]); 

錯誤是告訴你,LeaveManagement["new_leavedetails"]EntityReference(查找),而不是一個Guid

你可以投之前和之後投入Id內條件:

EntityReference detailsRef = (EntityReference)LeaveManagement["new_leavedetails"]; 
GetLeavedetails.Criteria.AddCondition("new_employeeleavecalculation", ConditionOperator.Equal, detailsRef.Id); 
相關問題