我試圖使用fetchxml從另一個記錄中獲取值以創建一個新的記錄。除了從選項集或查找字段獲取任何值之外,我已經設法實現所有工作。選項設置的人不會給出任何錯誤,但只是不設置字段,並且查找表示GUID的格式不正確,可能是因爲它沒有通過GUID。從CRM 2011中的FetchXml獲取選項集和查找字段值
任何人都可以幫我弄清楚如何獲得這些值嗎?
謝謝
編輯:我的代碼如下。選項集是評分(ts_grading)和我需要從提取中獲得的qualityStatement Guid(ts_quality_statement_id)。
string fetchXml = @"<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'>
<entity name='ts_self_assessment_item'>
<attribute name='ts_evidence_of_areas_of_improvement'/><attribute name='ts_evidence_of_strengths'/><attribute name='ts_expected_completion_date'/>
<attribute name='ts_grading'/><attribute name='ts_quality_statement_id'/>
<filter type='and'>
<condition attribute='ts_self_assessment_id' uitype='ts_self_assessment' operator='eq' value='" + selfAssessmentID + "'/></filter></entity></fetch>";
// Execute Fetch xml
EntityCollection selfAssessmentItemResult = Service.RetrieveMultiple(new FetchExpression(fetchXml));
foreach (var selfAssessment in selfAssessmentItemResult.Entities)
{
string areasOfImprovement = selfAssessment["ts_evidence_of_areas_of_improvement"].ToString();
string strengths = selfAssessment["ts_evidence_of_strengths"].ToString();
DateTime completionDate = Convert.ToDateTime(selfAssessment["ts_expected_completion_date"].ToString());
string grading = selfAssessment["ts_grading"].ToString();
Guid qualityStatement = new Guid(selfAssessment["ts_quality_statement_id"].ToString());
Guid parentSelfAssessment = new Guid(entity.Attributes["ts_self_assessmentid"].ToString());
}
}
你能發佈一些不適合你的代碼嗎? – 2012-07-09 16:51:32
Optionset值是數字而不是guid - 同意@PeterMajeed,代碼會有幫助! – glosrob 2012-07-09 21:35:56
我已經在我原來的帖子中發佈了代碼 – jimminybob 2012-07-10 07:52:09