2012-11-20 121 views
0

我有下面的代碼來獲取一個實體記錄功能錯誤:自定義工作流活動

private void FetchEvent(string EventId, IOrganizationService crmService) 
    { 
     // Create the ColumnSet to be retrieved. 
     ColumnSet columnSet = new ColumnSet(); 
     // Set the properties of the ColumnSet. 
     columnSet.AddColumn("campaignid"); 
     columnSet.AddColumn("name"); 
     columnSet.AddColumn("description"); 
     columnSet.AddColumn("renre_giftid"); 
     columnSet.AddColumn("ownerid"); 

     // Create the FilterExpression. 
     FilterExpression filterExpression = new FilterExpression(); 

     // Create the ConditionExpression. 
     ConditionExpression conditionExpression = new ConditionExpression(); 

     // Set the condition for the retrieval based on customer id field. 
     conditionExpression.AttributeName = "campaignid"; 
     conditionExpression.Operator = ConditionOperator.Equal; 
     conditionExpression.Values.Add(new string[]{EventId}); 

     filterExpression.FilterOperator = LogicalOperator.And; 
     // Set the properties of the filter. 
     filterExpression.Conditions.Add(conditionExpression); 

     // Create the QueryExpression object. 
     QueryExpression queryExpression = new QueryExpression(); 

     // Set the properties of the QueryExpression object. 
     queryExpression.EntityName = "campaign";//EntityName.campaign.ToString(); 
     queryExpression.ColumnSet = columnSet; 
     queryExpression.Criteria = filterExpression; 

     RetrieveMultipleRequest InvitationResponseRequest = new RetrieveMultipleRequest(); 
     InvitationResponseRequest.Query = queryExpression; 
     //InvitationResponseRequest.ReturnDynamicEntities = true; 

     eventEntity = (Entity)((RetrieveMultipleResponse)crmService.Execute(InvitationResponseRequest)).EntityCollection.Entities[0]; 
    } 

當我調試,達到此功能eventEntity = (Entity)((RetrieveMultipleResponse)crmService.Execute(InvitationResponseRequest)).EntityCollection.Entities[0];的最後一行之後它給出了一個例外,即:

條件for屬性'campaign.campaignid':類型'System.Guid'的預期參數,但收到'System.String []'。

請建議。

回答

2

你傳遞一個字符串數組作爲EntityId的值。

更改此:

conditionExpression.Values.Add(new string[]{EventId}); 

這樣:

conditionExpression.Values.Add(new Guid(EventId)); 

您可能還需要考慮在EVENTID參數輸入參數爲GUID變化的類型和固定帕斯卡爾套管駱駝一致性

+0

謝謝,它解決了這個問題... – Azeem

相關問題