我正在尝试使用 fetchxml 从另一条记录中获取值以创建新记录。除了从选项集或查找字段中获取任何值之外,我已经设法让这一切正常工作。选项集没有给出任何错误,但根本没有设置该字段,并且查找说 GUID 的格式不正确,大概是因为它没有通过 GUID。
谁能帮我弄清楚如何获得这些值?
谢谢
编辑:我的代码如下。选项集是评分 (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());
}
}